<div class="codetitle"> <span><a style="CURSOR: pointer" data="21450" class="copybut" id="copybut21450" onclick="doCopy('code21450')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code21450"> <br> <br> <br><script type="text/javascript"> <BR>var x; <BR>var y; <BR>function $(id) <BR>{ <BR>return document.getElementById(id) <BR>} <BR>function mousedown() <BR>{ <BR>x=event.clientX-$("px").style.pixelLeft; <BR>y=event.clientY-$("px").style.pixelTop; <BR>$("px").style.border="2px solid red"; <BR>$("px").onmousemove = mousemove; <BR>} <BR>function mouseup() <BR>{ <BR>$("px").onmousemove = ""; <BR>$("px").style.border=""; <BR>} <BR>function mousemove() <BR>{ <BR>$("px").style.pixelLeft=event.clientX-x; <BR>$("px").style.pixelTop=event.clientY-y; <BR>} <BR></script> <br> <br> <br><div id="px" style="position:absolute; left:100px; height:100px; width:100px; background-color:#FF0;">onmousedown="mousedown()" onmouseup="mouseup()" > <br> </div> <br> <br> <br> </div>