js触发弹出层

来源:互联网 发布:.net 获取请求的域名 编辑:程序博客网 时间:2024/05/16 05:03

<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>

原创粉丝点击