[英]How to stay on the same page when clicking the browser back button
I have 2 div's, with red color shown on the picture. 我有2格,照片上显示红色。
When loaded Div1 is shown and Div2 is hidden. 显示加载后的Div1,隐藏Div2。
Div1 has 4 divs in it with 4 onclick events which call ajax and hide div1 and show the second one with the loaded data. Div1中有4个div,其中包含4个onclick事件,这些事件调用ajax并隐藏div1并显示包含已加载数据的第二个。
When clicking the browser back button it takes me one page back and i want the page to get back to the default position with the div1 visible and div2 hidden. 单击浏览器的后退按钮时,我需要返回一页,并且我希望页面返回到默认位置,其中div1可见,并且div2隐藏。
How can i do it? 我该怎么做?
Use the history push state in html5 - https://developer.mozilla.org/en-US/docs/DOM/Manipulating_the_browser_history 在html5中使用历史记录推送状态-https: //developer.mozilla.org/zh-CN/docs/DOM/Manipulating_the_browser_history
There is also a js script somewhere to default to hashbangs in browsers that don't support the push state. 在不支持推入状态的浏览器中,默认情况下还有一个js脚本默认为hashbang。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.