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.
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.