html5 - difference between iframe, embed and object elements -


html5 defines several embedded content elements, which, bird's-eye view, seem similar point of being largely identical.

what actual difference between iframe, embed , object?

if want embed html file third-party site, of these elements use, , how differ?

<iframe>

the iframe element represents nested browsing context. html 5 standard - "the <iframe> element"

primarily used include resources other domains or subdomains can used include content same domain well. <iframe>'s strength embedded code 'live' , can communicate parent document.

<embed>

standardised in html 5, before non standard tag, admittedly implemented major browsers. behaviour prior html 5 can vary ...

the embed element provides integration point external (typically non-html) application or interactive content. (html 5 standard - "the <embed> element")

used embed content browser plugins. exceptions svg , html handled differently according standard.

the details of can , can not done embedded content browser plugin in question. svg can access embedded svg document parent like:

svg = document.getelementbyid("parent_id").getsvgdocument(); 

from inside embedded svg or html document can reach parent with:

parent = window.parent.document; 

for embedded html there no way @ embedded document parent (that have found).

<object>

the <object> element can represent external resource, which, depending on type of resource, either treated image, nested browsing context, or external resource processed plugin. (html 5 standard - "the <object> element")

conclusion

unless embedding svg or static best of using <iframe>. include svg use <embed> (if remember correctly <object> won't let script*). don't know why use <object> unless older browsers or flash (that don't work with).

  • as pointed out in comments below; scripts in <object> run parent , child contexts can't communicate directly. <embed> can context of child parent , vice versa. means can use scripts in parent manipulate child etc. part not possible <object> or <iframe> have set other mechanism instead, such the javascript postmessage api.

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -