使用 JQuery 更改 Vimeo 视频
如何更改嵌入的 vimeo 视频的 ID?例如,以下是嵌入代码:
<object width="578" height="325">
<param name="allowfullscreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=11527784&
server=vimeo.com&show_title=1&show_byline=0&show_portrait=0&color=00ADEF&fullscreen=1" />
<embed src="http://vimeo.com/moogaloop.swf?clip_id=11527784&
server=vimeo.com&show_title=1&show_byline=0&show_portrait=0&
color=00ADEF&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true"
allowscriptaccess="always" width="578" height="325"></embed></object>
如何使用 JQuery 或纯 JavaScript 更改对象值和嵌入源中的 clip_id?
其效果是改变了视频。我已经在 Firefox 上进行了测试,如果这不适用于所有浏览器,请告诉我!
感谢大家的帮助
How can I change the ID of the embedded vimeo video? Here is the embed code for example:
<object width="578" height="325">
<param name="allowfullscreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=11527784&
server=vimeo.com&show_title=1&show_byline=0&show_portrait=0&color=00ADEF&fullscreen=1" />
<embed src="http://vimeo.com/moogaloop.swf?clip_id=11527784&
server=vimeo.com&show_title=1&show_byline=0&show_portrait=0&
color=00ADEF&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true"
allowscriptaccess="always" width="578" height="325"></embed></object>
How can I change the clip_id in both the object value and the embed source using JQuery or just pure javascript?
The effect this has is that it changes the video. I have tested this on Firefox, if this won't work on all browsers please let me know!
Thanks all for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这会产生一些跨浏览器的影响。
您可能想看看关于SO的另一个问题。
您应该使用 SWFObject 插件来实现此目的,如 SolutionYogi 所述。
这是另一个相关问题:
如何使用 javascript 在 html 中交换 swf?
There are some cross-browser implications for this.
You might want to take a look at another question on SO.
You should use the SWFObject plugin for this as stated by SolutionYogi.
Here's another related question:
How to use javascript to swap swf in html?
我不确定你想“什么时候”更换它,所以我点击了一下就完成了。试试这个:
这个正则表达式将找到clip_id后跟任何数字并且仅数字,并将它们替换为新的id。您可以在两个包含clip_id 的网址上执行此操作。我很确定它适用于所有浏览器,尽管我现在无法测试它。
注意:我确信可以使用更好的正则表达式,但我对它们不是特别擅长,所以这就是我能想到的 atm。
希望这有帮助
I am not sure "when" you want to replace it, so I made it on click. Try this:
This regular expression will find clip_id followed by any numbers and only numbers and replace them with the new id. You can do this on both urls that contain clip_id. I am pretty sure it will work on all browsers, although I cant test it right now.
Note: I am sure that a better regular expression could be used, but I am not particulary good with them, so thats all I can come up with atm.
Hope this helps
Clip_url 是 vimeo 视频的 id。
clip_url is the id of the vimeo video.