Entry
From current window, how can you tell when a document fetched with window.open is done loading?
Mar 6th, 2000 08:57
Martin Honnen, Alon Katz,
If you control the HTML document you load with
var win = window.open('htmlDocument.html')
insert
<SCRIPT>
var loaded = false;
</SCRIPT>
<BODY ONLOAD="loaded = true;">
in it and check
if (win.loaded)
from the opening window. That is the best cross browser solution.
With IE4+ you can actually check
if (win.document.readyState == 'complete')
without any need to change the HTML document you load.
For instance try
var i = 0;
var r = new Array();
var win;
function checkReadyState () {
r[i++] = win.document.readyState;
if (win.document.readyState != 'complete')
setTimeout('checkReadyState()', 500);
else
alert(r);
}
win =
open ('http://www.faqts.com/knowledge-' +
'base/community/index.phtml/id/601');
checkReadyState();
If you don't control the document to load and want a NN solution there
is no reliable way. You can do some object checking for instance the
url in the example above contains lots of links so you could check for
the length of
win.document.links.length
if you know that in advance. But such access is only possible to
documents from the same host your script is loaded from.