Depending on when the code is executing, attach the handler using JavaScript:
if(window.onload) {
var _existing = window.onload;
window.onload = function() {
_existing();
foo();
};
}
else {
window.onload = foo;
}
, , , . , JavaScript . , , .
JavaScript .
addEventListener (W3C) attachEvent (IE).
quirksmode.org.