放置内容的div,一开始此div不显示
背景的div,在页面弹出的时候,设置背景的颜色和透明度
function popUpCenter(){
var o = $("#popUpContainer");
o.addClass("popUpWindow");
/**
1、窗口宽:document.body.clientWidth
2、div的宽度:o.css("width")
.css("width")取得的是css属性中的宽度。
.width()取得的是元素的width属性。
IE中使用.width()去不到css中设置的宽度,firefox则可以
3、$('.popUpWindowBg').css('filter', 'alpha(opacity=40)');
设置ie的透明度,此项写在css文件中没有效果。firefox则没问题。
*/
o.css({"left":parseInt(document.body.clientWidth)/2 - parseInt(o.css("width").substring(0,o.css("width").length -2))/2 + "px","top":parseInt(window.screen.availHeight)/2 - parseInt(o.css("width").substring(0,o.css("height").length -2))/2 - 50 + "px"});
o.show();
$('.popUpWindowBg').css('filter', 'alpha(opacity=40)');// IE8 USE
$('.popUpWindowBg').fadeIn(500);
}
$(document).ready(function(){
/**
关闭窗口
*/
$(".closeWindow").click(function(){
$('#popUpContainer').fadeOut(500);
$('.popUpWindowBg').fadeOut(500);
});
$(".popUpWindowBg").click(function(){
$('#popUpContainer').fadeOut(500);
$('.popUpWindowBg').fadeOut(500);
});
});
No comments:
Post a Comment