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?
Asked
Active
Viewed 1.6k times
7
2 Answers
6
Set a cookie on page 2.
If the cookie is detected on page 1, reload the page.
Diodeus - James MacFarlane
- 110,221
- 32
- 151
- 174
-
Diodeus, that was my intended approach but I though there might be a better way... Thanks for replying. – Mark_54 Feb 09 '12 at 17:59
-
1There are many examples of reading and setting cookies on this site already. – Diodeus - James MacFarlane Apr 29 '13 at 16:41
1
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.
Cody Gray
- 230,875
- 49
- 477
- 553
Ascalonian
- 13,791
- 18
- 70
- 103
-
1Ascalonian, I tried this to occur on the body onload but it doesn't seem to recognised the referrer if it's been referred via the back button. Any ideas? – Mark_54 Feb 09 '12 at 20:22