怎么把这个改成打开网页自动弹出层,而不是要点击按钮弹出层的? 100
<linkrel="stylesheet"href="main.css"/><scripttype="text/javascript"src="js/jquery-1.8...
<link rel="stylesheet" href="main.css" />
<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
<title>遮罩弹窗居中demo</title>
</head>
<body>
<div>
<button type="button" id="ClickMe">点击显示弹窗遮罩</button>
</div>
<div id="goodcover"></div>
<div id="code">
<table width="945" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/tctu.jpg"></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align="center" style="margin:0 auto"><a href="javascript:void(0)" id="closebt"><img src="images/zd.jpg"></a></td>
</tr>
</table>
</div>
<script>
$(function abc() {
//alert($(window).height());
$('#ClickMe').click(function() {
$('#code').center();
$('#goodcover').show();
$('#code').fadeIn();
});
$('#closebt').click(function() {
$('#code').hide();
$('#goodcover').hide();
});
$('#goodcover').click(function() {
$('#code').hide();
$('#goodcover').hide();
});
/*var val=$(window).height();
var codeheight=$("#code").height();
var topheight=(val-codeheight)/2;
$('#code').css('top',topheight);*/
jQuery.fn.center = function abc(loaded) {
var obj = this;
body_width = parseInt($(window).width());
body_height = parseInt($(window).height());
block_width = parseInt(obj.width());
block_height = parseInt(obj.height());
left_position = parseInt((body_width / 2) - (block_width / 2) + $(window).scrollLeft());
if (body_width < block_width) {
left_position = 0 + $(window).scrollLeft();
};
top_position = parseInt((body_height / 2) - (block_height / 2) + $(window).scrollTop());
if (body_height < block_height) {
top_position = 0 + $(window).scrollTop();
};
if (!loaded) {
obj.css({
'position': 'absolute'
});
obj.css({
'top': ($(window).height() - $('#code').height()) * 0.5,
'left': left_position
});
$(window).bind('resize', function() {
obj.center(!loaded);
});
$(window).bind('scroll', function() {
obj.center(!loaded);
});
} else {
obj.stop();
obj.css({
'position': 'absolute'
});
obj.animate({
'top': top_position
}, 200, 'linear');
}
}
})
</script> 展开
<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
<title>遮罩弹窗居中demo</title>
</head>
<body>
<div>
<button type="button" id="ClickMe">点击显示弹窗遮罩</button>
</div>
<div id="goodcover"></div>
<div id="code">
<table width="945" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/tctu.jpg"></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align="center" style="margin:0 auto"><a href="javascript:void(0)" id="closebt"><img src="images/zd.jpg"></a></td>
</tr>
</table>
</div>
<script>
$(function abc() {
//alert($(window).height());
$('#ClickMe').click(function() {
$('#code').center();
$('#goodcover').show();
$('#code').fadeIn();
});
$('#closebt').click(function() {
$('#code').hide();
$('#goodcover').hide();
});
$('#goodcover').click(function() {
$('#code').hide();
$('#goodcover').hide();
});
/*var val=$(window).height();
var codeheight=$("#code").height();
var topheight=(val-codeheight)/2;
$('#code').css('top',topheight);*/
jQuery.fn.center = function abc(loaded) {
var obj = this;
body_width = parseInt($(window).width());
body_height = parseInt($(window).height());
block_width = parseInt(obj.width());
block_height = parseInt(obj.height());
left_position = parseInt((body_width / 2) - (block_width / 2) + $(window).scrollLeft());
if (body_width < block_width) {
left_position = 0 + $(window).scrollLeft();
};
top_position = parseInt((body_height / 2) - (block_height / 2) + $(window).scrollTop());
if (body_height < block_height) {
top_position = 0 + $(window).scrollTop();
};
if (!loaded) {
obj.css({
'position': 'absolute'
});
obj.css({
'top': ($(window).height() - $('#code').height()) * 0.5,
'left': left_position
});
$(window).bind('resize', function() {
obj.center(!loaded);
});
$(window).bind('scroll', function() {
obj.center(!loaded);
});
} else {
obj.stop();
obj.css({
'position': 'absolute'
});
obj.animate({
'top': top_position
}, 200, 'linear');
}
}
})
</script> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询