By skipinator
Sunday, 24. February 2008, 04:00:08

force reload when pressing the back button
I am developing a web page that needs to reload from the sever any time a user presses the back button. I don't have a problem in IE, but Opera always wants to use the cached page, and not go back to the sever. I have added the headers in the head section:
<meta http-equiv=expires content=-1>
<meta http-equiv=Cache-Control CONTENT=no-cache>
<meta http-equiv=Pragma CONTENT=no-cache>
But still, Opera wants to used the cached page. Any ideas?
Thanks!
Skip
By rb79
Friday, 21. March 2008, 23:34:46

Today I finally solved this old, old issue and wanted to share my solution with the web-developer community! So here you go.
Put the following in your <head> tag:
<script>
function OperaReload() {
try {
var headElement = document.getElementsByTagName("head")[0];
if (headElement && headElement.innerHTML)
headElement.innerHTML += "<meta http-equiv=\"refresh\" content=\"1\">";
}
catch (e) {}
}
</script>
And in your body tag:
<body onUnload="OperaReload()">
Basically what I am doing is right before the page unloads, I am attaching a <META> tag that refreshes the page every second. Other browsers like Firefox, IE throw exception which I have enclosed in an empty try...catch statement.
HTH!
-rb79
Post edited Friday, 21. March 2008, 23:41:05
By Zoomer
Friday, 9. May 2008, 23:44:56

Great, now I have to think of something to defeat this.
