我想检测文档何时完成加载其所有内容。该文档来自主文档的第一帧,即
var frameList = window.top.document.getElementsByTagName("iframe");
if(frameList.length == 0)
{
frameList = window.top.document.getElementsByTagName("frame");
}
var frame = frameList[0];
var doc = ((frame.contentWindow) || (frame.contentDocument));
if (doc.document) doc = doc.document;
var readyState = doc.readyState;
现在,这种就绪状态有时会以正在加载的形式出现,在这种情况下,我在玩文档的元素时没有问题。但是,当这个就绪状态即将完成时,问题就来了,在这种情况下,我无法控制它的元素。我试图用 1ms 将计时器置于就绪状态,但这并没有帮助我。我放的计时器是这样的:
doc.prevState = readyState;
window.top.setTimeout(window.top.timeLoop,1,doc,fName);
function timeLoop(doc,fName)
{
var state1 = doc.readyState;
if(state1 != doc.prevState)
{
obj.doc.prevState = state1;
// Calling a function to check its state again. If state equals loaded or interactive or complete i am calling my desired funtion.
}
else
{
window.top.setTimeout(window.top.timeLoop2,1,doc,fName);
}
}