请帮忙看看下面这段代码

这是作一个可拖动的层,但是拖动的很不自如。由于是从网上copy,部分代码不懂意思,请告知;

drag = 0
move = 0
function mouseUp() {
move = 0
}
function mouseDown() {
clickleft = window.event.x - parseInt(dragObj.style.left)
clicktop = window.event.y - parseInt(dragObj.style.top)
dragObj.style.zIndex += 1
move = 1
}
function mouseMove() {
if (move) {
dragObj.style.left = window.event.x - clickleft
dragObj.style.top = window.event.y - clicktop

}
}

function Show(divid) {
divid.filters.revealTrans.apply();//什么意思
divid.style.visibility = "visible";
divid.filters.revealTrans.play();//什么意思
}
function Hide(divid) {
divid.filters.revealTrans.apply();//什么意思
divid.style.visibility = "hidden";
divid.filters.revealTrans.play();//什么意思
}
//-->

 1<div id="READ" style="FILTER: revealTrans(transition=23,duration=0.5) blendTrans(duration=0.5); LEFT: 100px; POSITION: absolute; TOP: 75px; WIDTH: 600px; Z-INDEX: 10">////什么意思   
 2<div align="center">
 3<center>
 4<table border="1" bordercolordark="#FFFFFF" bordercolorlight="#5E9BF7" cellpadding="0" cellspacing="0" width="90%">
 5<tr bgcolor="#ffedc8">
 6<td colspan="1"><div onmousedown="dragObj=READ;mouseDown()" onmousemove="mouseMove()" onmouseout="move=0" onmouseup="mouseUp()">标题栏 </div>
 7<td width="1%"><a href="javascript:void(Hide(READ))">■</a>
 8<tr>
 9<td bgcolor="#cccccc" colspan="4">
10<table border="0" cellspacing="4" width="100%">
11<tr>
12<td>
13<font color="Blue">一个可以拖动和关闭的层,有意思的是它每次关闭的效果都不一样。一个可以拖动和关闭的层,有意思的是它每次关闭的效果都不一样。一个可以拖动和关闭的层,有意思的是它每次关闭的效果都不一样。   
14</font></td></tr></table>
15</td></tr></td></td></tr></table>
16</center></div>   
17\---------------------------------------------------------------   
18  
19试试看这个,很短。   
20<span onmousedown="MouseDown(this)" onmousemove="MouseMove()" onmouseup="MouseUp()" style="position:absolute;width:200;height:200;background:blue;color:#ffffff;cursor:hand">aa</span>
21<script>   
22var Obj   
23function MouseDown(obj){   
24Obj=obj   
25Obj.setCapture()   
26Obj.l=event.x-Obj.style.pixelLeft   
27Obj.t=event.y-Obj.style.pixelTop   
28}   
29function MouseMove(){   
30if(Obj!=null){   
31Obj.style.left = event.x-Obj.l   
32Obj.style.top = event.y-Obj.t   
33}   
34}   
35function MouseUp(){   
36if(Obj!=null){   
37Obj.releaseCapture()   
38Obj=null   
39}   
40}   
41</script></div>
Published At
Categories with Web编程
comments powered by Disqus