Javascript 当弹出窗口未出现时,视频弹出窗口自动播放。我仍然能听到声音
我将此弹出窗口添加到我的网站,并尝试添加自动播放,但问题是即使每次刷新网站时弹出窗口都不会出现,您仍然可以听到声音。当弹出窗口未显示时,如何停止自动播放 我试图通过这样做来解决问题,但仍然不起作用Javascript 当弹出窗口未出现时,视频弹出窗口自动播放。我仍然能听到声音,javascript,jquery,iframe,Javascript,Jquery,Iframe,我将此弹出窗口添加到我的网站,并尝试添加自动播放,但问题是即使每次刷新网站时弹出窗口都不会出现,您仍然可以听到声音。当弹出窗口未显示时,如何停止自动播放 我试图通过这样做来解决问题,但仍然不起作用 <script> $( document ).ajaxComplete(function() { $("#popup_87 flex-video iframe").attr("src","https://www.youtube.com/embed/vYAVyEdBfEU?rel=0
<script>
$( document ).ajaxComplete(function() {
$("#popup_87 flex-video iframe").attr("src","https://www.youtube.com/embed/vYAVyEdBfEU?rel=0&autoplay=1;showinfo=0");
});
</script>
<!-- START POPUP CODE -->
<div id="popup_87" class="reveal-modal small" data-reveal aria-labelledby="popvideo" aria-hidden="true" role="dialog">
<div class="flex-video widescreen">
<iframe src="https://www.youtube.com/embed/vYAVyEdBfEU?rel=0&showinfo=0&autoplay=1" allowfullscreen="" frameborder="0" height="360" width="640"></iframe>
</div>
<a class="close-reveal-modal" aria-label="Close">×</a>
</div>
<div class="hide">
<a href="#" class="clickMe" data-reveal-id="popup_87">popvideo</a>
</div>
</div>
$(文档).ajaxComplete(函数(){
$(“#popup_87 flex video iframe”).attr(“src”,”https://www.youtube.com/embed/vYAVyEdBfEU?rel=0&autoplay=1;showinfo=0”);
});
/////
if(jQuery.cookie('popup{$popup['popup\u id']}')==未定义)
{
var cookieCount=1;
}
其他的
{
var cookieCount=jQuery.cookie('popup{$popup['popup_id']}');
}
var popCount={$popup['popup\u max\u display\u count']};
如果(cookieCount尝试
不确定是否要将此添加到ajaxComplete事件中。任何ajax调用都会调用此函数,这可能是您不想要的,并且在整个页面中都有随机行为。您将希望根据打开或关闭弹出窗口的时间触发功能。您好,蓝眼睛,我已经尝试了此代码,但它仍然不是自动播放。其他功能在哪里f您的代码?很难弄清楚您在做什么。很抱歉,我还是新手,非常感谢您的帮助,此弹出窗口是一个小部件。我尝试将loadvideo放在那里,但一直无法工作。您需要将其放在触发弹出窗口的位置
<script>
if (jQuery.cookie('popup{$popup['popup_id']}') === undefined)
{
var cookieCount = 1;
}
else
{
var cookieCount = jQuery.cookie('popup{$popup['popup_id']}');
}
var popCount = {$popup['popup_max_display_count']};
if (cookieCount <= popCount) {
setTimeout(function() {\$(".clickMe").trigger("click");}, 3000);
cookieCount++;
jQuery.cookie('popup{$popup['popup_id']}', cookieCount, { expires: {$popup['popup_clear_count_after']} });
}
</script>
<script>
function LoadVideo() {
// If it's visible
if($("#popup_87").is(":visible"))
{
// Load the video and auto play
$("#popup_87 flex-video iframe").attr("src","http://www.youtube.com/embed/vYAVyEdBfEU?rel=0&autoplay=1;showinfo=0");
}
}
</script>
<!-- START POPUP CODE -->
<div id="popup_87" class="reveal-modal small" data-reveal aria-labelledby="popvideo" aria-hidden="true" role="dialog">
<div class="flex-video widescreen">
<!-- Removed the source -->
<iframe allowfullscreen="" frameborder="0" height="360" width="640"></iframe>
</div>
<a class="close-reveal-modal" aria-label="Close">×</a>
</div>
<div class="hide">
<a href="#" class="clickMe" data-reveal-id="popup_87">popvideo</a>
</div>
<script>
if (jQuery.cookie('popup{$popup['popup_id']}') === undefined)
{
var cookieCount = 1;
}
else
{
var cookieCount = jQuery.cookie('popup{$popup['popup_id']}');
}
var popCount = {$popup['popup_max_display_count']};
if (cookieCount <= popCount) {
LoadVideo();
setTimeout(function() {\$(".clickMe").trigger("click");}, 3000);
cookieCount++;
jQuery.cookie('popup{$popup['popup_id']}', cookieCount, { expires: {$popup['popup_clear_count_after']} });
}
</script>