<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>
js觸發彈出層
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.