你的位置:首页 > Java教程

[Java教程]Js代码动态移动层


<html>
<head>
<title>动态移动的层</title>
<body bgcolor="#ADBAC9">
<div  id="div1" >
<div id=title onmousedown=DIVDown("div1") >标题</div>
<img id=close  onclick=Hide(div1)  border="0"

src="close.gif" width="15" height="15">
</div>

<div>http://www.999jiujiu.com/</div>

<script language="JavaScript">
var Obj="none";
var pX
var pY
document.onmousemove=DIVMove;
document.onmouseup=DIVUp;
function DIVDown(tag){
Obj=tag;
pX=parseInt(document.all(Obj).style.left)-event.x;
pY=parseInt(document.all(Obj).style.top)-event.y;
}
function DIVMove(){
if(Obj!="none"){
document.all(Obj).style.left=pX+event.x;
document.all(Obj).style.top=pY+event.y;
event.returnValue=false;
}
}
function DIVUp(){Obj="none";}
function Hide(divid){
divid.filters.revealTrans.apply();
divid.style.visibility = "hidden";
divid.filters.revealTrans.play();
}
</script>
</body>
</html>