I ran across a weird error today. I had a simple userscript which was adding a window.onload event to all the sites. But one of the sites had a <body onload="func();"> defined. What happened is that window.onload was working as usual but <body onload=""> stopped working for the site after installing userscript.
When I used window.body.onload instead both worked well. I know that window.onload and <body onload=""> are different way of doing the same thing but what is happening in window.body.onload which makes it work well with <body onload="">?
Window.onload and body tag's onload are the same event. So if you set the same event twice by two different methods it will only end up with the one value - one of the functions.
window.body.onload is a seperate event. Just another quirk of the DoM and what broswers do with it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With