Search code examples
javascriptdom-eventssimile

Need to use body onload event, but third party JavaScript library has hijacked it


I'm using Simile to draw dynamic timelines. I am also using an in-house library to add a comment blog. Our in-house library uses the body element's onload event to initialize.

<body onload="initComments('myID')">

But Simile seems to have hijacked the onload for their own purpose so that initComments('myID') never executes.

Short of changing the Simile code, how could I get my initializer to run?

I would prefer not to add another library (i.e. jQuery) just to solve the problem.


Solution

  • Use jQuery's $(document).ready event, which lets you add an arbitrary number of handlers (unlike onload).