简体   繁体   中英

Force a page refresh when page visited from back button

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?

Set a cookie on page 2.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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