如何动态添加 wmode=transparent 到 Youtube 嵌入代码?
我有几个由客户通过 CMS 添加的 Youtube 视频。我需要将以下内容添加到所有 Youtube src 链接:
?wmode=transparent
我该怎么做?
Youtube 嵌入代码的示例如下:
<iframe width="515" height="292" src="http://www.youtube.com/embed/p8IB-5PbL9U" frameborder="0" allowfullscreen></iframe>
这样做的原因是因为我有一个位于 Youtube 视频后面的 javascript 菜单,并且我读到这就是修复它的方法。
客户端根本不具备技术性,只是让他们从 Youtube 获取嵌入代码很困难,因此需要动态添加。
I have several Youtube videos that are added through a CMS by a client. I need to add the following to all Youtube src links:
?wmode=transparent
How would I do that?
An example of the Youtube embed code is as follows:
<iframe width="515" height="292" src="http://www.youtube.com/embed/p8IB-5PbL9U" frameborder="0" allowfullscreen></iframe>
The reason for doing this is because I have a javascript menu that is going behind a Youtube video and I've read that this is how you fix it.
The client isn't technical at all and just having them get the embed code from Youtube is a struggle, so it needs to be added dynamically.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您只需要向所有框架添加
?wmode=transparent
,请使用以下 JS 代码:If you just need to add
?wmode=transparent
to all the frames, have this JS code:您固定使用 iframe 吗?由于您无法直接访问底层对象,这使得这变得更加困难。如果可以的话,最好直接将对象嵌入到您的页面上
Are you fixed on using the iframe? It makes this a lot more difficult as you are unable to access the underlying object directly. If you can, it would be better to directly embed the object on your page as such
根据您的 CMS,您可以通过纯 PHP 来完成此操作,只需将其添加到每个 url 的末尾,或者您的或让 jQuery 为您完成工作。
Depending on your CMS you could do this through plain PHP, by just adding it at the end of each url, or your or make jQuery do the work for you.