You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by John <jo...@jak.com> on 2006/09/18 22:33:19 UTC

[myFaces-Tobago] - how to execute JavaScript file ONLY after DOM is fully rendered.

This has caused a never ending headache for us (particularly with IE),
when JavaScript starts to manipulate the DOM and objects aren't complete
yet.
Can't use <t:script> obviously.
 
 
What is the best practice?
 
Example?
 
Thanks,
John

Re: [myFaces-Tobago] - how to execute JavaScript file ONLY after DOM is fully rendered.

Posted by Volker Weber <we...@googlemail.com>.
Hi John,

you can do a loop with setTimeout() waiting for Tobago.pageIsComplete
becomes true. And you can use <t:script> to insert your script into
page.

like this:

<t:script>
  function doAferLoading() {
    if (!Tobago.pageIsComplete) {
      setTimeout("doAfterLoading()", 50);
    } else {
       // your script code
    }
  }

  doAfterLoading();
</t:script>

the value of Tobago.pageIsComplete is set to true by the tobago init
script after the initializing of the page is completed.

regards,
    Volker

2006/9/18, John <jo...@jak.com>:
>
>
> This has caused a never ending headache for us (particularly with IE), when
> JavaScript starts to manipulate the DOM and objects aren't complete yet.
> Can't use <t:script> obviously.
>
>
> What is the best practice?
>
> Example?
>
> Thanks,
> John