If I do an online onload
event for embedded objects, that seems to work but I can't seem to get the load
event working through addEventListener
. Is this expected?
The load event is fired when the whole page has loaded, including all dependent resources such as stylesheets and images. This is in contrast to DOMContentLoaded , which is fired as soon as the page DOM has been loaded, without waiting for resources to finish loading.
The onload in javascript is compatible with loading elements like CSS files, images, script files, etc. within a web page. The onload events are one of the most used and primarily part of the <body> tag.
Many different methods can be used to let JavaScript work with events: HTML event attributes can execute JavaScript code directly. HTML event attributes can call JavaScript functions. You can assign your own event handler functions to HTML elements.
Probably, but it may be browser dependent.
windows and images and iframes define their load events with addEventListener and attachEvent, but other load events are browser specific.
A script or link element's onload doesn't attach in IE, for instance.
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