gpt4 book ai didi

javascript - 当弹出窗口不出现时,视频弹出自动播放。我仍然能听到声音

转载 作者:行者123 更新时间:2023-11-27 22:51:42 27 4
gpt4 key购买 nike

我将这个弹出窗口添加到我的网站,并尝试添加自动播放,但问题是即使每次刷新网站时弹出窗口都不出现,你仍然可以听到声音。弹出窗口时如何停止自动播放不显示?

我尝试通过这样做来解决问题,但仍然无法正常工作

<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&amp;showinfo=0&amp;autoplay=1" allowfullscreen="" frameborder="0" height="360" width="640"></iframe>
</div>
<a class="close-reveal-modal" aria-label="Close">&#215;</a>
</div>
<div class="hide">
<a href="#" class="clickMe" data-reveal-id="popup_87">popvideo</a>
</div>

</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) {
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>

编辑由于添加了更多代码,因此在单击链接时放置触发器以将视频加载到弹出窗口中,否则不要在 iframe 中加载视频:

<!-- 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">&#215;</a>
</div>
<div class="hide">
<a href="#" class="clickMe" data-reveal-id="popup_87">popvideo</a>
</div>

我不确定以下代码是否有效,但我刚刚将 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) {
LoadVideo();
setTimeout(function() {\$(".clickMe").trigger("click");}, 3000);
cookieCount++;
jQuery.cookie('popup{$popup['popup_id']}', cookieCount, { expires: {$popup['popup_clear_count_after']} });
}
</script>

关于javascript - 当弹出窗口不出现时,视频弹出自动播放。我仍然能听到声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37998648/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com