$(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();
});
//if mask is clicked
$('#mask').click(function() {
$(this).hide();
$('.window').hide();
});
});
我用這個代碼的onload彈出框的瀏覽器,但是當我刷新我的瀏覽器每次表演這個彈出框不爲1的時候,請告訴我正確的方式。onload事件彈出窗口中打開每一次當我刷新
這不是Queness的jQuery的模態窗口腳本? – 2013-04-10 04:33:09
不,這只是簡單的模式彈出框。 – 2013-04-10 04:34:15
@AnmolRatanMohla [代碼太類似](http://www.queness.com/post/77/simple-jquery-modal-window-tutorial)是別的東西..相同的變量名稱,相同的值.. – Daedalus 2013-04-10 04:38:15