On 14-Aug-07, at 8:34 AM, csnyder wrote:

> The standard way to solve this problem seems to be implementing your
> own ondomload event. Perhaps this is something to be included in
> future versions of MochiKit (I'm using 1.3) as it would certainly make
> JavaScript suck less.
>
> Here's my hack implementation as a basic example. It requires a <p
> class="bottom"></p> at the end of the document, right before
> </body></html>...
>
> // signal ondomload when body element has loaded
> // loosely based on http://brothercake.com/site/resources/scripts/ 
> domready/
> ondomloadTries = 0;
> ondomloadDelay = 500;
> ondomloadInterval = setInterval( function() {
>   ondomloadTries++;
>   if ( ondomloadTries >= 12) {
>     log("Too many ondomload tries, something went wrong.");
>     clearInterval( ondomloadInterval );
>   }
>   bodies = getElementsByTagAndClassName('p', 'bottom');
>   log("Looking for body",ondomloadTries,bodies);
>   if ( bodies.length > 0 ) {
>     log("signal ondomload!");
>     try {
>       signal(window,'ondomload');
>     }
>     catch ( e ) {
>       log("EXCEPTION",e.message,e.errors);
>     }
>     clearInterval( ondomloadInterval );
>   }
> }, ondomloadDelay );

I haven't looked into this recently, but I was never happy with the  
way the ondomload stuff was implemented. In my code, I tend to do  
just add a <script> tag just before </body>. So in this case, you'd  
do something like:

<script type="text/javascript" charset="utf-8">
     signal(window,'ondomload');
</script>

</body>
</html>

Beau

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to