admin管理员组

文章数量:1271757

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?

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?

Share Improve this question edited Feb 9, 2012 at 18:15 JC JC 12.1k11 gold badges44 silver badges63 bronze badges asked Feb 9, 2012 at 17:46 Mark_54Mark_54 1,3034 gold badges15 silver badges21 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

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. forums as well.

本文标签: javascriptForce a page refresh when page visited from back buttonStack Overflow