简体   繁体   English

单击浏览器后退按钮时如何保持在同一页面上

[英]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.

相关问题 单击浏览器上的后退按钮时如何加载确切的页面? - How to load the exact page when clicking back button on browser? 如果用户在特定的导轨视图上输入任何 URL,如何防止浏览器的后退按钮并保持同一页面? - How to prevent browser's back button and stay same page if user entered any URL on specific rails view? 当我单击浏览器的“后退”按钮时,它应该转到同一页面的上一个活动 - when I clicking on Back button of browser , it should go to the previous activity of the same page 模态-浏览器后退按钮保持在同一站点上 - Modal - Browser back button stay on the same site 确认浏览器后退按钮保留在页面上 - Confirm browser back button else stay on page 单击浏览器的后退按钮时将客户返回到同一位置 - Return customer to same position when clicking browser's back button 在特定页面上单击浏览器后退按钮后如何重定向到主页 - How to redirect to home page after clicking browser back button, when on a particular page 单击浏览器的后退按钮时重定向到特定页面 - redirecting to a specific page when clicking browser's back button 付款后在浏览器中单击后退按钮可返回到其他页面 - Return to different page when clicking back button in browser after payment 更改浏览器中按下后退按钮的行为以保留在同一站点上 - Altering behaviour on back button pressed in browser to stay on the same site
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM