Why does my embedded YouTube video work in Firefox, but not Internet Explorer?

こ雲淡風輕ζ 提交于 2019-12-05 22:19:45

问题


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


回答1:


Try this:

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



回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/1469250/why-does-my-embedded-youtube-video-work-in-firefox-but-not-internet-explorer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!