我知道之前有人问过这个问题,但我无法让我的代码正常工作。
我启动了 fancybox:
$(document).ready(function() {
$('.fancybox').on('click', function(event) {
event.preventDefault();
$.fancybox({
'type' : 'iframe',
// hide the related video suggestions and autoplay the video
'href' : this.href = this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1') + '&autoplay=1',
'overlayShow' : true,
'centerOnScroll' : true,
'speedIn' : 100,
'speedOut' : 50,
'width' : 640,
'height' : 480
});
});
});
然后调用 iframe:
<a class="fancybox fancybox.iframe" href="http://vimeo.com/123456">
但是当我关闭弹出窗口然后尝试再次打开该视频时,视频没有显示,任何人都可以帮助我解决它,大多数解决方案与“类型”:“内联”相关,并且不适用于我的示例。
非常感谢,
最佳答案
如果您使用 fancybox v2.x,那么您的脚本中不需要(过时的)选项 (v1.3.4)。你宁愿这样做
1).设置你的 html 像
<a class="fancybox" href="http://vimeo.com/123456">
...删除特殊类fancybox.iframe
2).添加辅助媒体 js 文件,如下所示:
<script type="text/javascript" src="../helpers/jquery.fancybox-media.js"></script>
...相应地设置你的路径
3).使用这个脚本
jQuery(document).ready(function ($) {
$('.fancybox').fancybox({
helpers: {
media: {}
}
});
});
...并为自己省去一些麻烦。
参见JSFIDDLE
如果需要,您可以添加更多 API 选项。检查 http://fancyapps.com/fancybox/#docs 的 v2.x 选项
关于jquery - FancyBox Iframe 第二次未关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17202012/