Mark_54
Mark_54

Reputation: 1303

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?

Upvotes: 7

Views: 16721

Answers (2)

Ascalonian
Ascalonian

Reputation: 15193

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.

Upvotes: 1

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114417

Set a cookie on page 2.

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

Upvotes: 6

Related Questions