Reputation: 7427
This code doesn't seem to work:
document.body.onload = function () { ... }
I know there is a onload
event for the body tag in html, but how come you can't access it from JavaScript? Is window.onload
same as <body onload="...
It basically never triggers.
Upvotes: 0
Views: 1835
Reputation: 107052
body.onload
. When you attach the event in the HTML code, it actually attaches to window.onload
. So that's the one you should use.Upvotes: 5