ajax调用后如何对URL进行哈希处理?
据我所知,window.location.hash = hash_url
用于对 URL 进行哈希处理。假设我在 http://www.example.com
并且我想对其进行哈希化。 window.location.hash = #foo
将导致 URL http://example.com/#foo
但是当我的实际 URL 是 http://example.com/bar
但在 hasifying 之后我希望它 http://example.com/#foo
不像 http://example .com/bar/#foo
。 Twitter hashify 是如何工作的?
What I know that window.location.hash = hash_url
is used to hashify the URL. Suppose I am at http://www.example.com
And I want to hashify it. window.location.hash = #foo
will lead to the URL http://example.com/#foo
But what about when My actual URL ishttp://example.com/bar
But after hasifying I want it to http://example.com/#foo
not like http://example.com/bar/#foo
.
How twitter hashify works?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,你们可能错了:)
http://html5demos.com/history/
其次,唯一的事情我不确定是否跨浏览器兼容,
最后但并非最不重要的一点是,为什么该栏是否存在很重要?
First of all You lot can be wrong :)
http://html5demos.com/history/
secondly The only thing im not sure about is cross browser compatable,
last but not least why would it matter whether the bar is there or not ?
如果不重新加载页面,则无法更改 URL 的非哈希部分。
Twitter 的工作原理是发送从
twitter.com/X
到twitter.com/#!/X
的 HTTP 重定向。It is not possible to change the non-hash portion of the URL without reloading the page.
Twitter works by sending an HTTP redirect from
twitter.com/X
totwitter.com/#!/X
.如果您位于
http://example.com/bar
并且想要访问http://example.com/#foo
,则必须使用window. location = 'http://example.com/#foo'
,因为使用hash
您只能更改 URL 的哈希值,而不能更改路径。If you are at
http://example.com/bar
and want to go tohttp://example.com/#foo
you must usewindow.location = 'http://example.com/#foo'
, because withhash
you can only change the hash of your URL, not the path.