而使用AJAX请求,使浏览器后退按钮的工作 [英] Making Browser Back button work while using AJAX requests

查看:103
本文介绍了而使用AJAX请求,使浏览器后退按钮的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个web应用检索使用AJAX大量的数据,这些数据大大修改了加载页面取决于什么按钮,用户点击(比方说,点击按钮1取页从state0到状态1等..)

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..)

此外,如果按钮号码传递给服务器作为GET变量,服务器返回的页面中的正确的状态。

Further, if the button number is passed to the server as a GET variable, the server returns the page in the correct state.

不用说,前进/后退浏览器按钮不起作用,因为URL是不是在通过AJAX实现状态的变化改变了。

Needless to say, the back / forward browser buttons do not work because the URL is not changed during state changes accomplished 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.

推荐答案

花一些时间去通过<一个href="http://stackoverflow.com/questions/946582/browser-back-button-and-dynamic-elements/946654#946654">some. <一href="http://stackoverflow.com/questions/1115303/ajax-paging-enable-back-button/1115455#1115455">of. <一href="http://stackoverflow.com/questions/629765/enabling-back-fwd-key-events-for-an-ajax-application">the. previous 问题。 <一href="http://stackoverflow.com/questions/657310/experiences-with-javascript-history-frameworks">on. <一href="http://stackoverflow.com/questions/568719/is-monitoring-location-hash-a-solution-for-history-in-xhr-apps">this. <一href="http://stackoverflow.com/questions/940964/could-a-page-display-diferrent-content-if-the-url-hash-changes">topic.

Take some time to go through some. of. the. previous. questions. on. this. topic.

提示:使用hash的人! ( window.location.hash 这是)

Hint: use the hash man! (window.location.hash that is)

这篇关于而使用AJAX请求,使浏览器后退按钮的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆