7
votes

I'm using the following code to display a YouTube video.

<object width="425" height="344">
    <param name="movie" 
           value="**URL**">
    </param>
    <param name="allowFullScreen" 
           value="true">
    </param>
    <embed src="**URL**" 
           type="application/xshockwave-flash" 
           allowfullscreen="true" 
           width="425"
           height="344">
    </embed>
</object>

It works in Firefox, but why doesn't it in Internet Explorer?

I'm a totally new to web development, so I'm running into all these wonderful inconsistencies that you veterans are used to ;)

3

3 Answers

7
votes

Try this:

<object type="application/x-shockwave-flash" data="VID_URL" width="425" height="344">
    <param name="movie" value="VID_URL" />
</object>
8
votes

To elucidate, it doesn't work because the object tag is incomplete. Firefox gives up on the object element and uses the fallback old-school embed element instead. IE doesn't support embed so you get nothing.

An object element must at least have a type attribute telling it what plugin to use and a data attribute telling it what to send the plugin. In IE you also need to mirror the data attribute in a <param name="movie"> value inside the object because it runs plugins differently.

IE won't ‘stream’ partially-loaded Flash files this way though. To get that, you have to use an ActiveX classid instead of the type to tell it which plugin to use. If you care about this (and you might not: for small files, stub loaders, and files that are useless until complete, it makes no difference) then you have to start serving combinations of nested objects or embeds, which quickly becomes confusing.

1
votes

Previously wasted a few hours working through the same issue. Different cause though...

For IE9, YouTube embeds (at least iframes) were not working because I had previously added Tracking Protection to IE for Google ad servers. In this case, I had to disable the tracking protection (Safety > Tracking Protection) or click the button immediately to the right of the address bar ('Some content is filtered on this site') that alerts end users to filtered content.