简单DIV拖动

<script>
var x,y
var v=0
function $(obj){
return document.getElementById(obj)
}
document.onmouseup=new Function("v=0");


function mdown(){
if(event.srcElement.className=="ye"){
v=1;
x=event.clientX-$("t").style.pixelLeft;
y=event.clientY-$("t").style.pixelTop;
}
}
function mmove(){
if(v==0){
return;
}else{
$("t").style.pixelLeft=event.clientX-x;
$("t").style.pixelTop=event.clientY-y;
}
}


</script>
<div class=ye style="position:absolute;width:100px;height:100px;background:#ccc;border:1px solid #000;" id="t" onmousemove="mmove()" onmousedown="mdown()"></div>

你可能感兴趣的:(IE)