Topic: Run a function after page load -- but not from <body> tag
I'm playing around with my own cheap version of an ajax chat system.
To start getting chat events, I need to call a javascript function just one time. I'm currently using <body onload = "...">. Which is not a great place for this, because I won't know which parts of the website really will need to call that function -- only the ones that have a chat box, should make a call to this function.
So, really, I'd like to stick a call to the function into the div that will do the chatter reporting. How should I do this?
So I want it in here:
<div id="chatbox">...</div>
and not in the <body> tag.
Thoughts?