<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>拖拽</title>
 </head>
 <style type="text/css">
 #one{background:red;height:100px;width:100px;position:absolute;}
 </style>
 <body>
<div id="one"></div>
<script type="text/javascript">
window.onload = function(){
var oDiv = document.getElementById('one');

var mouseStartX=0;
var mouseStartY=0;

var divStartX=0;
var divStartY=0; oDiv.onmousedown = function(ev){ var oEvent=ev||event; oDiv.style.cursor = 'move';
mouseStartX=oEvent.clientX;
mouseStartY=oEvent.clientY;

divStartX=oDiv.offsetLeft;
divStartY=oDiv.offsetTop;
if(oDiv.setCapture){
oDiv.onmousemove =move;
oDiv.onmouseup =stopMove
this.element.setCapture();
}
else
{
document.addEventListener('mousemove',move, true);
document.addEventListener('mouseup',stopMove, true);
}
} function move (ev)
{
var oEvent=ev||window.event;
oDiv.style.left=oEvent.clientX-mouseStartX+divStartX+'px';
oDiv.style.top=oEvent.clientY-mouseStartY+divStartY+'px';
} function stopMove()
{
oDiv.style.cursor='default';
if(oDiv.releaseCapture){
oDiv.onmousemove=null;
oDiv.onmouseup = null;
oDiv.releaseCapture();
}else{
document.removeEventListener('mousemove',move,true);
document.removeEventListener('mouseup',stopMove.true);
}
}}
  </script>
 </body>
</html>
最后放开鼠标时就出错了,帮看看怎么回事