Question about readyState property and onload event

S

szimek

Hi!

I've got an IE-only app and there's a main page with an iframe. In the
main page there's the following js code:

window.onload = done;
function done() {
frame.finishPage();
}

And the code in the frame:

document.body.onload = finishPage; // is it supported by non-IE
browsers?
function finishPage() {
if(parent.document.readyState != "completed") // parent.document
points to the main page
return;
else
do lots of strange stuff;
}

The problems are:
- is document.body.onload supported by non-IE browsers? Can I safely
switch it to window.onload or are there some differences?
- finishPage function is called for the first time by "done" function,
which should be triggered only when the main page is already loaded
(window.onload). But the readyState inside finishPage is
"interactive", not "completed" (of course in IE only). Why? Shouldn't
it be "completed" if it was triggered by window.onload event?
- how to refactor this code to be FF friendly? I thought about
removing the readyState check completly, because I thought it will be
"completed" anyway, but now I'm not really sure how to do it.

Thanks in advance for any suggestions.
 
T

Thomas 'PointedEars' Lahn

szimek said:
I've got an IE-only app and there's a main page with an iframe. In the
main page there's the following js code:

window.onload = done;
function done() {
frame.finishPage();
}

And the code in the frame:

document.body.onload = finishPage; // is it supported by non-IE
browsers?
function finishPage() {
if(parent.document.readyState != "completed") // parent.document
points to the main page
return;
else
do lots of strange stuff;
}

The problems are:
- is document.body.onload supported by non-IE browsers?

That is unlikely as it is not part of "DOM Level 0" or W3C DOM Level 2 HTML.
Can I safely switch it to window.onload or are there some differences?

[...]
- how to refactor this code to be FF friendly?

See above.


PointedEars
 

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,777
Messages
2,569,604
Members
45,234
Latest member
SkyeWeems

Latest Threads

Top