onload eventHandler
recently handgestrickt netzwerk had the problem, that two scripts had to be added to one of our customers websites and both scripts needed an onload eventHandler. the problem is, that only the last eventHandler will be excecuted. so we needed a solution for this. the best one is to collect all function calls in one function and then execute this function onload.
Simon Willison wrote a handy Javascript function for this called addLoadEvent:
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}
//examples
addLoadEvent(nameOfSomeFunctionToRunOnPageLoad);
addLoadEvent(nameOfAnotherFunctionToRunOnPageLoad);source: http://simon.incutio.com/archive/2004/05/26/addLoadEvent

