admin管理员组文章数量:1353646
I have a site that dynamically updates the URL hash as the user navigates through it (it's a Backbone.js app and I'm using pushState).
I'd like the user to be able to tweet the full URL, including the hash.
I'm using the Twitter share button, but it seems to only share the basic URL path, not the hash, which is quite important:
<a href="" class="twitter-share-button">Tweet</a>
Any ideas for how I can let users share the hash as well?
Thanks for your help.
I have a site that dynamically updates the URL hash as the user navigates through it (it's a Backbone.js app and I'm using pushState).
I'd like the user to be able to tweet the full URL, including the hash.
I'm using the Twitter share button, but it seems to only share the basic URL path, not the hash, which is quite important:
<a href="https://twitter./share" class="twitter-share-button">Tweet</a>
Any ideas for how I can let users share the hash as well?
Thanks for your help.
Share Improve this question asked Apr 25, 2012 at 8:22 RichardRichard 33k30 gold badges111 silver badges146 bronze badges 3- 2 You are using pushState, so there shouldn't be a hash unless the user uses an old browser. – ThiefMaster Commented Apr 25, 2012 at 8:23
- 1 Sure, but I need to support users with old browsers... – Richard Commented Apr 25, 2012 at 8:42
- I think this may be the best answer: stackoverflow./questions/9215806/… I hope Twitter add an option to include this by default. – Richard Commented Apr 30, 2012 at 21:45
2 Answers
Reset to default 13the trick is to replace the hash sign with its html encoded character which is : %23
Does that button use the referer? If yes, you are out of luck - the hash is never sent to the server.
However, when using pushState you don't need a hash unless the user's browser is too old - but for everyone with a recent browser it should work fine as the referer will be whatever is currently used in the address bar.
本文标签: javascriptTwitter share button share hash part of URLStack Overflow
版权声明:本文标题:javascript - Twitter share button: share hash part of URL? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743856943a2551027.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论