onload and/or readystate==4 on IE 5

A

Andrew Poulos

Whenever the content of a frame ('mainFrame') has loaded I call a
function. The following code works in IE 5.5+ but IE 5 does nothing (I
have a different technique for MZ, FF...):

window.onload = function() {
var doc = document.getElementById("mainFrame");
doc.onreadystatechange = function() {
if (doc.readyState == 'complete') {
// do stuff
}
}
}
</script>
</head>

<frameset rows="60,100%,60" cols="*" border="0" framespacing="0"
frameborder="0">
<frame src="top.htm" name="topFrame"id="topFrame" scrolling="auto" noresize>
<frame src="about:blank" name="mainFrame" id="mainFrame"
scrolling="auto" noresize>
....

I've tried a variety of things
var doc = window.frames['mainFrame'];
var doc = window.frames[1];
....
doc.onload = function() {
....

Short of putting an onload handler in every page that will be loaded
into the frame, is there a way to get the onload event, of a page in a
frame, trigger a call to a function in the parent frameset?


Andrew Poulos
 
V

VK

IE 6, all curent releases of FF and NN are acting properly on the
onload event in the frameset: it fires only after "onload" received
from each and every frame. So this script covers all current browsers:
....
<script>
function test() {
var windowObject = self.frames['frameName']; // or
window.frames['frameName']; - egale
var docObject = win.document;
// etc...
}
window.onload = test;
</script>
</head>

<frameset>
....
</frameset>

For legacy browsers I remember some big FAQ 2-3 years ago "How to
detect onload/onerror in my frame", but it was all connected to the
inter-domain security. The frame technics is on the market since
Netscape 2.0 and is one of the most bug-free.

Two things to check:
1) In frameset *any* scripting is *ignored* after the closing </head>
tag.
2) "about:blank" is not a real page but a system DLL call. Unlikely but
it can be some extra security block in IE 5.0. Try to use some real
page "blank.html" instead.

If both things are checked and the script above did not start to work,
reinstall the browser of question, it's broken.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top