【发布时间】:2011-03-11 02:36:19
【问题描述】:
$(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('fast');
$('#mask').fadeTo('fast');
//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('fast');
//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();
$('#mask').fadeOut();
$('.window').fadeOut();
});
//if mask is clicked
$('#mask').click(function () {
$(this).unhide();
$('.window').unhide();
});
});
【问题讨论】:
-
一般来说,您应该在正文中提出您的问题并使用描述性标题。您发布的代码与您明显的问题无关,因此投反对票。
标签: javascript jquery dialog window modal-dialog