延时后模态弹出框隐藏()
|
这应该是相当简单的,但事实并非如此。我想要(我的客户想要)一个弹出的灯箱窗口,其中包含嵌入的youtube视频,该页面在加载后立即显示,然后在视频播放完毕后消失。我正在努力使正常的灯箱之一在页面加载时弹出,因此设法使以下工作正常进行:
$(document).ready(function() {
//Put in the DIV id you want to display
launchWindow(\'#dialog1\');
//if close button is clicked
$(\'.window #close\').click(function () {
$(\'#mask\').hide();
$(\'.window\').hide();
});
//if mask is clicked
$(\'#mask\').click(function () {
$(this).hide();
$(\'.window\').hide();
});
$(\"#mask\").delay(24000).hide();
$(\".window\").delay(24000).hide();
});
function launchWindow(id) {
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set heigth and width to mask to fill up the whole screen
$(\'#mask\').css({\'width\':maskWidth,\'height\':maskHeight});
//transition effect
$(\'#mask\').fadeIn(1000);
$(\'#mask\').fadeTo(\"slow\",0.8);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css(\'top\', winH/2-$(id).height());
$(id).css(\'left\', winW/2-$(id).width()/2);
//transition effect
$(id).fadeIn(2000);
}
<div id=\"boxes\">
<div id=\"dialog1\" class=\"window\">
<iframe width=\"725\" height=\"442\" src=\"http://www.youtube.com/embed/SMlRXI_N6u4?autoplay=1\" frameborder=\"0\" allowfullscreen id=\"youtube-popup\"></iframe>
</div>
</div>
<div id=\"mask\"></div>
弹出效果很好。然后
$(\"#mask\").delay(24000).hide();
$(\".window\").delay(24000).hide();
命令应该在24秒(视频时长)后隐藏两个覆盖图。但是,它们在作品中任何位置的存在都根本不会弹出,更不用说24秒后消失了。
有任何想法吗?
没有找到相关结果
已邀请:
1 个回复
抬澈帅沮
。 尽管还有更多工作要做,但其他可能性是使用setTimeout或入队。