MDL-10249 Created addonload JavaScript function that can be used to add onload handlers, instead of using <body onload> which breaks things.

This commit is contained in:
sam_marshall
2007-06-25 14:38:02 +00:00
parent 50ebd1258e
commit 7470d6de7a
2 changed files with 17 additions and 2 deletions
+14
View File
@@ -420,3 +420,17 @@ function insertAtCursor(myField, myValue) {
myField.value += myValue;
}
}
/*
Call instead of setting window.onload directly or setting body onload=.
Adds your function to a chain of functions rather than overwriting anything
that exists.
*/
function addonload(fn) {
var oldhandler=window.onload;
window.onload=function() {
if(oldhandler) oldhandler();
fn();
}
}