【发布时间】:2011-07-06 18:05:48
【问题描述】:
我的页面上有一个链接图像,点击它会加载一个 Fancybox 模态框。它成功地做到了,但我希望视频自动播放。如果我将 YouTube URL 设置为 autoplay=1,隐藏的 DIV 会在页面加载时在后台播放。
// Here is the linked image
<a id="inline" href="#video"><img src="someimage.jpg" alt="Description" /></a>
// Here is the hidden DIV
<div style="display:none">
<div id="video">
<iframe title="YouTube video player" width="640" height="390" src="###YOUTUBE LINK###rel=0&hd=1&autoplay=0" frameborder="0"></iframe>
</div>
</div>
// Here is the script
<script type="text/javascript">
$("a#inline").fancybox({
'hideOnContentClick': true,
});
</script>
我的猜测是我需要做一些 Bind() 事件和字符串替换来将 autoplay=0 更改为 autoplay=1 但我尝试了一些变体但没有成功
有什么想法吗?
【问题讨论】:
标签: jquery replace youtube fancybox