Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What html tags support the onload javascript event?

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?

like image 406
rook Avatar asked Nov 24 '10 22:11

rook


People also ask

What can be used in load event in JavaScript?

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).

Is there an onload function in JavaScript?

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.

Can I use onload with Div?

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.

How do you load a function in JavaScript?

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.


2 Answers

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.

like image 170
Vlad Avatar answered Sep 29 '22 02:09

Vlad


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).

like image 24
25 revs, 4 users 83% Avatar answered Sep 29 '22 03:09

25 revs, 4 users 83%