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.

  1. var oldLoad = window.onload;
  2. window.onload = function() {
  3. oldLoad();
  4. function2();
  5. }

Comments are closed.