Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a cross-browser standard on-load event for HTML's "object" tag?

I am aware that IE supports the onreadystatechange attribute on the object tag, but this doesn't seem to be a standard way thus all other browsers do not support it.

Update: To clarify, I am not looking for the DOM Load event, I am looking for the load event of the object tag itself(e.g. an object tag embedding a PDF file into a page).

In a way, I am looking for something similar to img's onload event /complete attribute for the object tag.

like image 263
Hyangelo Avatar asked Oct 13 '11 15:10

Hyangelo


People also ask

Which HTML elements support onload?

According to this page, you can use onload with: <body> , <frame> , <frameset> , <iframe> , <img> , <link> , and <script> .

Is there an onload function in JavaScript?

JavaScript has a window onload event to launch certain functions whenever a web page is loaded. The onload event is also used for verification of type and version of visitor's browser. Further cookies can also be checked through the onload attribute. The attribute of onload triggers when the object is loaded in HTML.

Does Div work onload?

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.

Can I use script onload?

onload is most often used within the <body> element to execute a script once a web page has completely loaded all content (including images, script files, CSS files, etc.). However, it can be used on other elements as well (see "Supported HTML tags" below).


1 Answers

The <object onload> attribute works well in latest versions of Firefox, Chrome and Opera (I've just tested it).

Also, the expression 'onload' in document.createElement('object') evaluates to true in Chrome and Opera; naturally, Firefox is an exception because such event support check doesn't work there generally. kangax describes cross-browser event support detection at http://perfectionkills.com/detecting-event-support-without-browser-sniffing/

like image 58
duri Avatar answered Oct 04 '22 06:10

duri