我怎么说“你需要安装闪存...”对于嵌入的 YouTube 剪辑(如果用户没有 flash 或 html5)
我使用以下代码在我的网站上嵌入 youtube 剪辑:
<object width="259" height="215" style="margin:auto; width:262px; height:217px; position:relative;">
<param name="movie" value="http://www.youtube.com/v/<?php echo $yt_id; ?>&hl=en&fs=1&rel=0&hl=en&fs=1&rel=0&showinfo=0&autoplay=1"></param>
<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/<?php echo $yt_id; ?>&hl=en&fs=1&rel=0&hl=en&fs=1&rel=0&showinfo=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="259" height="215"></embed>
</object>
<p style="margin-top:12px; width: 259px; text-align:center;"><?php echo $yt_title; ?></p>
这在配备 html5 或配备 flash 的浏览器中效果很好。但是,如果我尝试在未安装 Flash 的情况下使用 IE 7/8,则会得到以下占位符:
如何获得“此视频需要 flash 播放器”?
更新:这是我使用 Richard JP Le Guen 的解决方案的最终代码。它工作完美。
<object width="259" height="215" style="margin:auto; width:262px; height:217px; position:relative;">
<param name="movie" value="http://www.youtube.com/v/<?php echo $yt_id; ?>&hl=en&fs=1&rel=0&hl=en&fs=1&rel=0&showinfo=0&autoplay=1" />
<param name="wmode" value="opaque" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/<?php echo $yt_id; ?>&hl=en&fs=1&rel=0&hl=en&fs=1&rel=0&showinfo=0&autoplay=1" allowfullscreen="true" width="259" height="215">
<param name="wmode" value="opaque" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflashplayer" style="display: block; text-align:center; padding-top:40px;">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
I'm embedding youtube clips on my site with the following code:
<object width="259" height="215" style="margin:auto; width:262px; height:217px; position:relative;">
<param name="movie" value="http://www.youtube.com/v/<?php echo $yt_id; ?>&hl=en&fs=1&rel=0&hl=en&fs=1&rel=0&showinfo=0&autoplay=1"></param>
<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/<?php echo $yt_id; ?>&hl=en&fs=1&rel=0&hl=en&fs=1&rel=0&showinfo=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="259" height="215"></embed>
</object>
<p style="margin-top:12px; width: 259px; text-align:center;"><?php echo $yt_title; ?></p>
which works great in html5 equipped or flash equipped browsers. However, if i try using IE 7/8 without flash installed, i get this placeholder:
how can i get a "this video requieres flash player" instead?
update: this is my final code using Richard JP Le Guen's solution. it works perfectly.
<object width="259" height="215" style="margin:auto; width:262px; height:217px; position:relative;">
<param name="movie" value="http://www.youtube.com/v/<?php echo $yt_id; ?>&hl=en&fs=1&rel=0&hl=en&fs=1&rel=0&showinfo=0&autoplay=1" />
<param name="wmode" value="opaque" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/<?php echo $yt_id; ?>&hl=en&fs=1&rel=0&hl=en&fs=1&rel=0&showinfo=0&autoplay=1" allowfullscreen="true" width="259" height="215">
<param name="wmode" value="opaque" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflashplayer" style="display: block; text-align:center; padding-top:40px;">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这看起来像是 SWFObject 的用途。
借助 SWFObject,您可以使用 JavaScript 动态添加
通过 Google 快速搜索 SWFObject 和 YouTube,找到了本文。我没有时间阅读它,但看起来它会有所帮助。
This looks like the sort of thing one uses SWFObject for.
With SWFObject, you add the
<object>
and<embed>
dynamically, using JavaScript. In your (normal, standards-compliant) HTML you would have a message like "You need Flash and JavaScript to view this video" and then use SWFObject to swap out that content for the video.A quick Google search for SWFObject and YouTube yielded this article. I don't have time to read it, but it looks like it could help.
YouTube 使用
标签:虽然我不认为它属于任何官方标准...
编辑:添加了
标记到示例,以显示 YouTube 正在做什么。
YouTube uses a
<noembed>
tag:Although I do not think it belongs to any official standard...
Edit: Added
<embed>
tag to example, to show what YouTube is doing.