Well, if your function is called myFunction and you are *really* calling addLoadEvent like this: addLoadEvent(myFunction()); then your problem is simple: you need to call addLoadEvent like this: addLoadEvent(myFunction); Notice the difference?
Jason Bunting _____ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Kieran O'Neill Sent: Tuesday, June 26, 2007 5:02 PM To: [email protected] Subject: [mochikit] Functions called by addLoadEvent can't access the DOM I found a bit of a weird situation (bug)? with addLoadEvent. I have a function that I want to execute synchronously once the page has loaded, doing some fairly minor but important page changes. However, when I attach it using addLoadEvent(myFunction()), code within myFunction can't get to the DOM. (ie: Calls to both MochiKit DOM functions and to getElementById fail.) When I execute the same function from the html using <body onLoad="myFunction()" >, it works fine and has access to the DOM. Anyway, for now simply calling the function using onLoad is a solution, although it would obviously be better, for future compatibility with other scripts, if I could rather use addLoadEvent. I am using MochiKit 1.3.1 and have tested this on Firefox HYPERLINK "http://2.0.0.3"2.0.0.3 on Linux. I wasn't sure if this was a bug, or if there was something I just wasn't understanding about how addLoadEvent works, so I posted it here. Anyway, I hope this is useful. Regards, Kieran No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.9.9/871 - Release Date: 6/26/2007 4:16 PM No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.9.9/871 - Release Date: 6/26/2007 4:16 PM --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
