<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>点击按钮弹出可以移动的层</title>
<script>
var falpha
falpha=0
function fchange(){
if (falpha!=100){
table1.style.filter="alpha(opacity="+falpha+")";
falpha=falpha+10;
setTimeout("fchange()",200)
}
else { falpha=0;
}
}
function sss(){
table1.style.height=(window.document.body.clientHeight>window.document.body.scrollHeight)?window.document.body.clientHeight:window.document.body.scrollHeight;
table1.style.width="100%";
table1.style.backgroundColor="#cccccc";
table1.style.display='block'
table1.style.filter="alpha(opacity=100)"
table2.style.left=window.document.body.scrollWidth/2-100;
table2.style.top=window.document.body.offsetHeight/2-100
table2.style.display='block'
fchange()
}
function freset(){
table1.style.display='none'
table2.style.display='none'
}
</script>
<script language="javascript" type="text/javascript">
<!--
var ie=document.all
var ns6=document.getElementById&&!document.all
var dragapproved=false
var z,x,y
function move(e){
if (dragapproved){
z.style.left=ns6? temp1+e.clientX-x: temp1+event.clientX-x
z.style.top=ns6? temp2+e.clientY-y : temp2+event.clientY-y
return false
}
}
function drags(e){
if (!ie&&!ns6)
return
var firedobj=ns6? e.target : event.srcElement
var topelement=ns6? "HTML" : "BODY"
while (firedobj.tagName!=topelement&&firedobj.className!="table2"){
firedobj=ns6? firedobj.parentNode : firedobj.parentElement
}
if (firedobj.className=="table2"){
dragapproved=true
z=firedobj
temp1=parseInt(z.style.left+0)
temp2=parseInt(z.style.top+0)
x=ns6? e.clientX: event.clientX
y=ns6? e.clientY: event.clientY
document.onmousemove=move
return false
}
}
document.onmousedown=drags
document.onmouseup=new Function("dragapproved=false")
//-->
</script>
</head>
<body>
<div id="table1" style=" background:#FFFFFF; display: none; position: absolute;z-index:1;filter:alpha(opacity=40)" oncontextmenu="return false">
</div>
<div class="table2" id="table2" style="position:absolute; onmousedown=MDown(table2);background:#ffffff; display:none; z-index:2; width:300; height:200; border-left:solid #000000 1px; border-top:solid #000000 1px; border-bottom:solid #000000 1px; border-right:solid #000000 1px; cursor:move;" cellspacing="0" cellpadding="0" oncontextmenu="return false">
<TABLE border=0 width=100% height=100%>
<TR>
<TD align=right valign=top><span onClick="freset()" style="cursor:pointer">×</span>
</TD>
</TR>
</TABLE>
</div>
<center>
<input name="button" type="button" onClick="sss()" value='点击'>
</center>
</body>
</html>