There can only be one function assigned to window.onload
. But, you can have multiple event listeners that listen to that same event.
// cross browser way to add an event listener
function addListener(event, obj, fn) {
if (obj.addEventListener) {
obj.addEventListener(event, fn, false); // modern browsers
} else {
obj.attachEvent("on"+event, fn); // older versions of IE
}
}
addListener('load', window, myFunc1); // you can have multiple ones of these
addListener('load', window, myFunc2); // you can have multiple ones of these
window.onload = myFunc3; // one and only one of these
See the MDN doc on addEventListener for more details.
In your specific case, you can use this code for your onload handler and let the other one use window.onload
:
// cross browser way to add an event listener
function addListener(event, obj, fn) {
if (obj.addEventListener) {
obj.addEventListener(event, fn, false); // modern browsers
} else {
obj.attachEvent("on"+event, fn); // older versions of IE
}
}
addListener('load', window, function() {
maxHeight_main_column();
...
});