A typical code fragment obtained from the YouTube embed feature looks like this:
<object width="660" height="405">
<param name="movie" value="http://www.youtube.com/v/NWHfY_lvKIQ?fs=1&hl=en_GB&border=1"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/NWHfY_lvKIQ?fs=1&hl=en_GB&border=1"
type="application/x-shockwave-flash"
allowscriptaccess="always"
allowfullscreen="true"
width="660"
height="405">
</embed>
</object>
Now, the <embed>
element has a type attribute to tell the browser it is embedding a flash file, but for browsers using the <object>
tag, there appears to be no information available to the browser!
Why is a classid or codebase attribute not required here? The only options I can think of are:
<embed>
tagI can't find documentation to verify either option. And I'm curious!
EDIT: found a great comparison of Flash embedding techniques here. Still want to know how it works though...
I experimented a bit and found that removing the <embed>
tag causes IE to fail to embed the video. I was surprised that IE used the embed tag, so delved deeper. If you just want to know the answer, scroll down the 'summary' at the end!
The simplest thing which worked in IE8 is this:
<embed src="http://www.youtube.com/v/NWHfY_lvKIQ?fs=1&hl=en_GB&border=1"
width="660"
height="405">
</embed>
No type attribute there, so the browser must be checking the MIME type of the src attribute to figure out what to do. I verified this by serving a Flash file with a different MIME type - it would not play unless I provided a type attribute of application/x-shockwave-flash (this behaviour is documented for IE here)
Of course, if an <object>
tag does contain the classid, the <embed>
will be ignored, which is what you'd expect. I verified this by having the embed tag reference another video
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" WIDTH="660" HEIGHT="405" id="adobeWay">
<PARAM NAME=movie VALUE="http://www.youtube.com/v/NWHfY_lvKIQ?fs=1&hl=en_GB&border=1">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<embed src="http://youtube.com/v/rIFh1ydXWmg"
type="application/x-shockwave-flash"
allowscriptaccess="always"
allowfullscreen="true"
width="660"
height="405">
</embed>
</OBJECT>
When the object tag is used, the Flash plugin doesn't care what the MIME type of the movie is. Again, I verified this by serving a valid SWF file with a different MIME type.
Remove the classid from that last test, and you'd get the alternative video in the <embed>
tag. This leads me to wonder why there's any <param>
tags at all if they are just being ignored in a YouTube-style embed.
When there's no classid
attribute in an <object>
(or any other way of determining the required plugin, like a data attribute), IE renders whatever it can find inside the object tag, which means it will render the <embed>
tag (IE calls this object fallback). If that tag contains no type
attribute, then the MIME type of the src
is used to determine the correct plugin to use.
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