Categories
Code

Append to Body onLoad

I looked for a long time how I could add JavaScript functions to an HTML document’s onLoad attribute.

Eventually I found this, something so obvious that I had considered trying it but foolishly didn’t try.

[code lang=”JavaScript”]
var oldLoad = window.onload;
window.onload = function() {
oldLoad();
function2();
}
[/code]