admin管理员组文章数量:1325137
I am writing a web application which retrieves a lot of data using AJAX which substantially modifies the loaded page depending on what button the user clicked (Let's say that clicking on button1 takes the page from state0 to state1 and so on..)
Further, if the button number is passed to the server as a GET variable, the server returns the page in the correct state.
Needless to say, the back / forward browser buttons do not work because the URL is not changed during state changes acplished through AJAX.
So, my question is, how can I make the browser back / forward buttons work?
Is it possible to supply the browser with the correct URL every time the state changes; but stop the page from reloading?
Please note that this question is only about browser back / forward buttons. I can create custom back / forward buttons but that is not what I want to do.
I am writing a web application which retrieves a lot of data using AJAX which substantially modifies the loaded page depending on what button the user clicked (Let's say that clicking on button1 takes the page from state0 to state1 and so on..)
Further, if the button number is passed to the server as a GET variable, the server returns the page in the correct state.
Needless to say, the back / forward browser buttons do not work because the URL is not changed during state changes acplished through AJAX.
So, my question is, how can I make the browser back / forward buttons work?
Is it possible to supply the browser with the correct URL every time the state changes; but stop the page from reloading?
Please note that this question is only about browser back / forward buttons. I can create custom back / forward buttons but that is not what I want to do.
Share Improve this question asked Nov 4, 2009 at 12:00 KJ SaxenaKJ Saxena 21.8k24 gold badges85 silver badges111 bronze badges 1- 2 Try Googling for "back button AJAX" - you'll get a ton of results. This problem is well known, and there are lots of ways to fix it. – Dominic Rodger Commented Nov 4, 2009 at 12:09
2 Answers
Reset to default 8Take some time to go through some. of. the. previous. questions. on. this. topic.
Hint: use the hash man! (window.location.hash
that is)
You will have to use # capabilities of your URL to store your intermediate Ajax requests in browser history. If you use any Javascript library there will probably be a solution in the library itself or in a form of a munity extension/plugin.
For instance there's a plugin for jQuery here.
Google for browser history ajax
本文标签: javascriptMaking Browser Back button work while using AJAX requestsStack Overflow
版权声明:本文标题:javascript - Making Browser Back button work while using AJAX requests - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742173452a2427141.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论