简体   繁体   English

按下返回按钮后停止页面刷新

[英]Stop page refreshing after back button pressed

Is there any way to stop a web page from refreshing when it is displayed after someone presses the back button? 在有人按下“后退”按钮后显示网页时,是否有任何方法可以阻止网页刷新?

My web page shows different information every time it is refreshed. 每次刷新时,我的网页都会显示不同的信息。 I want it to show whatever it was showing before the user moved to another page. 我希望它显示用户移动到另一个页面之前显示的内容。

Is this possible? 这可能吗? If so how? 如果可以,怎么办?

No. 没有。

The contents of the window when the 'back' button is pressed is actually data your browser has cached so preventing 'back' is not going to help. 按下“后退”按钮时窗口的内容实际上是浏览器已缓存的数据,因此防止“后退”将无济于事。

You could maybe use a hash though. 您也许可以使用哈希。

go to

stackoverflow.com

then go to 然后去

stackoverflow.com#foo

then go to 然后去

stackoverflow.com#foobar

If you hit the back button you'll notice the hash changes but the page does not refresh. 如果单击后退按钮,您会注意到哈希值发生了变化,但是页面没有刷新。

Sorry about the formatting. 抱歉,格式化。 Blame SO! 怪死了!

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

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