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
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745300513a4621407.html
评论列表(0条)