admin管理员组文章数量:1419666
I make a ajax request with .load. It is working good. But i have a problem with the url bar. I want change the url bar. For example. When the ajax loads about/contact page. I want to change the url bar to about/contact.
I used this.
window.location.replace = about/contact;
But now, he redirect direct to this page. But I do not want, that the page is redirect to that url. How can i fix that?
Thanks!
I make a ajax request with .load. It is working good. But i have a problem with the url bar. I want change the url bar. For example. When the ajax loads about/contact page. I want to change the url bar to about/contact.
I used this.
window.location.replace = about/contact;
But now, he redirect direct to this page. But I do not want, that the page is redirect to that url. How can i fix that?
Thanks!
Share Improve this question asked Sep 19, 2012 at 7:11 Mike VierwindMike Vierwind 1,5204 gold badges24 silver badges44 bronze badges 3-
You can not do that. However, you could add an anchor to the URL which does not reload the page, e.g.
www.example.#about
– Uooo Commented Sep 19, 2012 at 7:13 - See this answer: stackoverflow./questions/824349/… – Jeff Commented Sep 19, 2012 at 7:14
- @w4rumy Are you sure about that?. CNTRL + F Adding and modifying history entries – Ohgodwhy Commented Sep 19, 2012 at 7:18
2 Answers
Reset to default 5You can do this with the History API, though support is not universal yet, though good in browsers other than IE. For an example of it in use: http://html5demos./history. It will modify the visible URL as you want, and will also allow you to use the back button to go back to previous states.
Suggest you use something like history.js to this as it behaves accordingly for browsers that do not yet support the history API. It will use the History API first, and if that isn't present will use the hash technique.
If you want to do-it-yourself, then definately look up on the History API and how it works, here's some places to start: article 1, article 2
Use the ajax history plugin, like jquery-address.
Look at this : https://stackoverflow./questions/116446/what-is-the-best-back-button-jquery-plugin
本文标签: javascriptFake the url bar with ajax and windowlocationStack Overflow
版权声明:本文标题:javascript - Fake the url bar with ajax and window.location - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745300511a2652343.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论