0
我想做一个JavaScript弹出白色广告,然后关闭10秒后,我已经搜索了互联网的任何事情做到这一点,但我找不到任何东西。Javascript自动关闭弹出窗口10秒后
我不是一个非常过期的JavaScript程序员。
<script type="text/javascript">
$(document).ready(function() {
var id = '#dialog';
//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()/2);
$(id).css('left', winW/2-$(id).width()/2);
//transition effect
$(id).fadeIn(2000);
//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();
$('#mask').hide();
$('.window').hide();
});
});
</script>
最好的问候,
叶普小号
请格式化你的代码,使其可读。 – Jake 2012-04-17 08:04:53
@JeppeS:请花点时间阅读:http://stackoverflow.com/editing-help和http://sscce.org/ – spender 2012-04-17 08:06:13
您的代码使用JQuery。一定要包含所需的文件。 – Basilevs 2012-04-17 08:17:13