views:

53

answers:

3

I'm altering the DOM tree in plain JS and need to know when the changes get fully rendered on screen (mostly care about document dimensions).

window.onload=function(){
    ss = document.styleSheets[0];
    for(i = 0; i < ss.cssRules.length; i++) { ss.deleteRule(i) };
    ss.addRule('p', 'color: red;')
    // ... many more
    // call some other function when the page is fully rendered?
}

TIA.

A: 

why don't use jQuery ? it provides that functionality and can help you a lot.

Edgar Zavala
This runs on a mobile device, so I'd prefer not to add dependencies.
alex
A: 

MyLibrary (i.e. your library) provides a documentready listener:

http://www.cinsoft.net/mylib-doc.asp#attachdocumentreadylistener >

RobG
A: 

Have settled on

window.setTimeout(function(){
// code
}, 50);

so far.

alex