I tried creating the following three files:
top.htm:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Top Frame</title>
<script type="text/javascript">
function showMessage(message) {
if(window.console) {
console.log(message);
}
}
</script>
</head>
<body onload="showMessage('Top loaded')">
<p>This is the top frame!</p>
</body>
</html>
bottom.htm:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Bottom Frame</title>
<script type="text/javascript">
function showMessage(message) {
if(window.console) {
console.log(message);
}
}
</script>
</head>
<body onload="showMessage('Bottom loaded')">
<p>This is the bottom frame!</p>
</body>
</html>
and frametest.htm:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>TopBottom</title>
<script type="text/javascript">
function showMessage(message) {
if(window.console) {
console.log(message);
}
}
function setTopFrameSource() {
showMessage('setTopFrameSource begin');
var t = document.getElementById('topframe');
t.src = 'top.htm';
showMessage('setTopFrameSource end');
}
</script>
</head>
<frameset id='TopBottom' rows="*, *" onload = "showMessage('frameset loaded')">
<frame id="topframe">
<frame id="bottomframe" src="bottom.htm" onload = "setTopFrameSource()">
</frameset>
</html>
I deliberately load the frames bottom first, then top, as this is more likely to show if it works.
If I just open the page, either by entering its url (even repeatedly) or by navigating to it from another page in IE or Firefox, everything works fine.
The logging messages appear as expected:
- Bottom loaded
- setTopFrameSource begin
- setTopFrameSource end
- Top loaded
- frameset loaded
If, however, the page has already loaded and I hit refresh, I get this sequence of messages:
- Top loaded
- Bottom loaded
- setTopFrameSource begin
- setTopFrameSource end
- frameset loaded
I have tried various meta tags to force the browser not to cache anything, but nothing works.
Is the whole approach flawed or can someone show me the error of my ways?