I know that img
body
and iframe
allow you to add onload=
to the tag and have to execute. What other tags support the onload
action? Do you know of a list of all tags and the actions the support?
The onload event can be used to check the visitor's browser type and browser version, and load the proper version of the web page based on the information. The onload event can also be used to deal with cookies (see "More Examples" below).
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.
The onload event can only be used on the document(body) itself, frames, images, and scripts. In other words, it can be attached to only body and/or each external resource. The div is not an external resource and it's loaded as part of the body, so the onload event doesn't apply there.
load() . The load() method attaches an event handler to the load event. The load event occurs when a specified element has been loaded. This event works with elements associated with a URL (image, script, frame, iframe), and the window object.
The specs for html4 only mention body
and frameset
: http://www.w3.org/TR/html4/interact/scripts.html#h-18.2.3
I think it's browser dependent.
You can also use it on <script>
tags except IE where you need onreadystatechange
for the same effect.
I think it also works on <object>
elements in some browsers (but just a few).
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