gpt4 book ai didi

javascript - 在 jQuery 脚本中放置 15 秒延迟

转载 作者:行者123 更新时间:2023-11-28 01:34:06 25 4
gpt4 key购买 nike

我有一个脚本,可以在单击后关闭 iframe。我需要当您单击 iframe 内的链接时延迟 15 秒以在 iframe 内加载页面,并在 15 秒后 iframe 自动关闭。

			$(window).on('blur',function(e) {    
if($(this).data('mouseIn') != 'yes')return;
$('iframe').filter(function(){
return $(this).data('mouseIn') == 'yes';
}).trigger('iframeclick');
});

$(window).mouseenter(function(){
$(this).data('mouseIn', 'yes');
}).mouseleave(function(){
$(this).data('mouseIn', 'no');
});

$('iframe').mouseenter(function(){
$(this).data('mouseIn', 'yes');
$(window).data('mouseIn', 'yes');
}).mouseleave(function(){
$(this).data('mouseIn', null);
});

$('iframe').on('iframeclick', function(){
$(this).hide()
});

$('<input type="text" style="position:absolute;opacity:0;height:0px;width:0px;"/>').appendTo(document.body).blur(function(){
$(window).trigger('blur');
}).focus();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<iframe style="width:400px;
height:250px;" src="//example.com"></iframe>

最佳答案

如果你想坚持使用 Jquery,你可以使用 .delay()

http://api.jquery.com/delay/

要在 iframe 关闭前等待 15 秒,您应该这样做:

$('iframe').on('iframeclick', function(){
$(this).delay(15000).hide();
}

以一种简单的方式,在“隐藏”操作之前延迟 15 秒

关于javascript - 在 jQuery 脚本中放置 15 秒延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29161541/

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