Force a page refresh when page visited from back button

旧巷老猫 提交于 2019-12-18 05:56:34

问题


How can I force a page refresh of page 1 when a user returns to it from page 2 by pressing the back button? Are there vbscript or javascript approaches or is it down to set the 'no cache' somehow?


回答1:


Set a cookie on page 2.

If the cookie is detected on page 1, reload the page.




回答2:


What about doing something like this?

<script>
    if   (document.referrer == "http://www.page2.html") 
          window.location.reload(); 
    }
</script>

Just throw that at the top of your page 1 and this should work.

Update

I also found a solution on the Webdeveloper.com forums as well.



来源:https://stackoverflow.com/questions/9215993/force-a-page-refresh-when-page-visited-from-back-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!