Jquery Fancybox视频在关闭时继续播放
刚刚实现的Fancybox在页面加载时弹出-但是,当用户点击Fancybox返回网站时,歌曲将再次开始播放。你知道是什么引起的吗 链接:Jquery Fancybox视频在关闭时继续播放,jquery,html,fancybox,Jquery,Html,Fancybox,刚刚实现的Fancybox在页面加载时弹出-但是,当用户点击Fancybox返回网站时,歌曲将再次开始播放。你知道是什么引起的吗 链接: $(文档).ready(函数(){ $(“.populink”).fancybox(); setTimeout('$(“.populink”).trigger(“click”)”,100); }); $(“a.more”)。单击(函数(){ $.fancybox({ “填充”:0, “自动缩放”:false, “transitionIn”:“无”, “tra
$(文档).ready(函数(){
$(“.populink”).fancybox();
setTimeout('$(“.populink”).trigger(“click”)”,100);
});
$(“a.more”)。单击(函数(){
$.fancybox({
“填充”:0,
“自动缩放”:false,
“transitionIn”:“无”,
“transitionOut”:“无”,
“title”:this.title,
“宽度”:680,
‘高度’:495,
'href':this.href.replace(新的RegExp(“watch\\?v=,“i”),'v/'),
“类型”:“swf”,
“swf”:{
'wmode':'transparent',
“allowfullscreen”:“true”
}
});
首先,为了避免潜在的冲突,您应该加载jQuery的单一版本(您有两个版本:v1.4和v1.7)
其次,与jQuery一样,您正在加载两个不同版本的fancybox(您有:v1.3.4和v2.0.3)
第三,我个人认为为视频设置内联
iframe不是一个好主意,因为您无法真正控制iframe
中发生的事情。此外,它可能会增加页面负载的开销和其他潜在问题,如您遇到的问题
好消息是,您可以在fancybox中“按需”打开视频,换句话说,只有在您需要时才可以打开,而不是隐藏在页面中并在后台播放……因此我建议您对代码进行以下更改:
html
<!-- FANCYBOX POPUP -->
<a class="popupLink" href="#popup"></a>
<div id="popup">
<iframe width="853" height="480" src="http://www.youtube.com/embed/Qw7k_erTgow?autoplay=1" frameborder="0" allowfullscreen></iframe>
</div>
<!-- .popup -->
<script type="text/javascript">
$(document).ready(function() {
$(".popupLink").fancybox();
window.setTimeout('$(".popupLink").trigger("click")', 100);
});
</script>
<script type="text/javascript">
$("a.more").click(function() {
$.fancybox({
'padding' : 0,
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'title' : this.title,
'width' : 680,
'height' : 495,
'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
'type' : 'swf',
'swf' : {
'wmode' : 'transparent',
'allowfullscreen' : 'true'
}
});
<a class="popupLink" href="http://www.youtube.com/embed/Qw7k_erTgow?autoplay=1&wmode=opaque"></a>
$(document).ready(function() {
$(".popupLink").fancybox({
"padding": 1,
"type": "iframe",
"width": 853,
"height": 480
});
window.setTimeout('$(".popupLink").trigger("click")', 100);
}); // ready