I know you can use the window.onload event to make functions run, but is there a way for a script to query if the document is ready or not?
Something like
function update()
{
if( !document.ready() ) // don't do unless document loaded
return ;
}
window.setInterval( 'update();', 100 ) ;
Cannot change the element, and no jQuery/other libraries.
Answer
Here you go:
var tid = setInterval( function () {
if ( document.readyState !== 'complete' ) return;
clearInterval( tid );
// do your work
}, 100 );
Read about the document.readyState
property here. I am not sure if all current browsers implement it.
No comments:
Post a Comment