js触发弹出层

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>messagBox</title>
<style>
#messWindow{
position:absolute;z-index:1;filter:alpha(opacity=0);background-color:#000000;visibility:hidden;
}
#promptWindow{
position:absolute; z-index:3; width: 540px; height:300px;background-color:#fff;display:none;
}
#titleBar{
background-color:#f1edcf;color:#000;padding-left:4px;padding-top:2px;font-weight:bold;font-size:14px; width:540px;height:22px;line-height:22px;
}
#titleBar span{
float:left; cursor:hand;
font-weight:normal;
}
#mainContent{
width:540px;height:255px;
}
#bottomBar{
background-color:#f7f7f7; width:540px; height:23px;
}
#bottomBar span{
float:right;
}
</style>
</head>
<body topmargin=0 leftmargin=0>
<div id="messWindow"></div>
<div id="promptWindow" align="center">
  <div  id="titleBar"><span onClick="hide()">×</span><span>   标题栏</span></div>
  <div  id="mainContent">主要显示区域</div>
  <div  id="bottomBar"><span>
    <input type="button" value=" 关 闭 " onClick="hide()" />
    </span> </div>
  <!-- <iframe style="position:absolute; visibility:inherit; top:0px; left:0px; width:540px; height:300px; z-index:-1; filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';"></iframe>-->
</div>
<li><a href="#" onClick="show()">触发弹出层</a></li>
<script type="text/javascript">
var obj=document.getElementById("messWindow")
var  t = new Object();
function show(){
 obj.style.visibility="visible";
 obj.style.width=document.documentElement.clientWidth  /* document.body.clientWidth */;
 obj.style.height=document.documentElement.clientHeight;
 document.getElementById('promptWindow').style.top= (document.documentElement.offsetHeight-300)/2;
 document.getElementById('promptWindow').style.left= (document.documentElement.offsetWidth-540)/2;
 document.getElementById('promptWindow').style.display='block';
 if(obj.filters.alpha.opacity>5){
  obj.filters.alpha.opacity=25;
  clearTimeout(t.timer1);
  return;
 }else{
  obj.filters.alpha.opacity+=5;
  t.timer1=setTimeout("show()",5)
 }
 return;
}
function hide(){
    // alert();
 if(obj.filters.alpha.opacity<=0){
  obj.filters.alpha.opacity=0;
  obj.style.visibility="hidden"
  document.getElementById('promptWindow').style.display='none';
  clearTimeout(t.timer2)
  return;
 }else{
  obj.filters.alpha.opacity-=5;
  t.timer2=setTimeout("hide()",5);
 }
 return;
}
</script>
</body></html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值