On the client side, if i want to attach some function for page load event, i used to implement the window.onload event :
window.onload = func;
But this approach has some difficulties. Because this will completely overwrite any other functions that were attached. So I began to search for a better solition. After visiting some saint google links, i got the answer. window.addEventListener (for mozilla,gecko, safari and konqueror), window.attachEvent (for internet explorer) and document.addEventListener (for opera 7) methods can be used for attaching any kind of method in a safe way. All i need to wrap these nifty methods into a function.
Here is the code snippet that you can use :
function AddOnload(func){
if(window.addEventListener)
window.addEventListener('load', func, false);
else if(document.addEventListener)
document.addEventListener('load', func, false);
else if(window.attachEvent)
window.attachEvent('onload', func);
}
Happy codings ;)