简体   繁体   English

使用 jquery ajax 和 PHP 处理浏览器“后退按钮”

[英]Working of browser 'back button' using jquery ajax and PHP


I am working on an application which involves lot of ajax requests for updating the HTML content.I have a dashboard with a fix left menu or accordian panel which takes the event and based on the events I have to update the center portion of the page using ajax.我正在开发一个应用程序,该应用程序涉及更新 HTML 内容的大量 ajax 请求。我有一个带有修复左侧菜单或手风琴面板的仪表板,它接受事件并根据事件我必须使用更新页面的中心部分阿贾克斯。
Issue: I am facing issue with the back button of the browser as I am not refreshing the page.问题:我遇到浏览器后退按钮的问题,因为我没有刷新页面。 I want that the user should be able to navigate back and forth through the ajax content ,but as I don't change the URL it redirects the user to the previous page they came from and destroys all the information entered by the user in the fields.我希望用户应该能够在 ajax 内容中来回导航,但是由于我没有更改 URL,它会将用户重定向到他们来自的上一页并销毁用户在字段中输入的所有信息.
While making a search I came through this website which is quite popular and manages a playlist on the left and a player at the bottom without refreshing the page,but the URL changes for different content the show.在进行搜索时,我访问了这个非常受欢迎的网站,网站管理左侧的播放列表和底部的播放器,无需刷新页面,但URL会因节目的不同内容而变化。
I am not sure if there is any specific framework that can be used or it can be achieved via normal code.我不确定是否有任何特定的框架可以使用或者可以通过普通代码实现。
Any help in pointing me to the right links or suggestions over it would be helpful.任何帮助我指向正确链接或建议的帮助都会有所帮助。
Thank you谢谢

What you seem to want is history.js .你似乎想要的是history.js It uses the HTML5 history API to navigate (and you can fire events upon change), and it also supports older browsers by using hashbangs .它使用 HTML5 历史 API 进行导航(您可以在更改时触发事件),并且它还使用hashbangs支持旧浏览器。

Essentially the browser will not load any new page, but you can still change the URL to reflect changes (and have the users bookmark pages etc.).基本上浏览器不会加载任何新页面,但您仍然可以更改 URL 以反映更改(并让用户为页面添加书签等)。

Take a look at their demos to see if it's what you're looking for.看看他们的演示,看看它是否是你要找的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM