一个例子,lz改改吧
IE测试通过<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 4</title>
<script>
var isSD=false;
var x=0;
var y=0;
var can_move=false;
function SD(){
isSD=true;
}
function JS(){
isSD=false;
}
function mouse_down(){
x=event.x;
y=event.y;
can_move=true;
}
function mouse_move(){
if(can_move&&!isSD){
var top=document.all.div1.style.top;
var left=document.all.div1.style.left;
document.all.div1.style.top=parseInt(top.substring(0,top.length-2))+(event.y-y);
document.all.div1.style.left=parseInt(left.substring(0,left.length-2))+(event.x-x);
y=event.y;
x=event.x;
}
}
function mouse_up(){
can_move=false;
}
document.onmousemove=mouse_move;
</script>
</head>
<body>
<div id=div1 onmousedown='mouse_down()' onmouseup='mouse_up()' style='position:absolute;top:100px;left:100px;width:400px;height:300px;background-color:#cccccc'>
<input type=button style="position:absolute;top:5px;left:5px" value="锁定" onclick=SD()>
<input type=button style="position:absolute;top:5px;left:50px" value="解锁" onclick=JS()>
<textarea style='position:absolute;top:30px;left:5px;width:390px;height:250px'>
</textarea></div>
</body>
</html>