<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
var Obj=''
document.onmouseup=MUp
document.onmousemove=MMove
function MDown(){
if(event.button==2) {
document.all.cursor="move"
}
Obj=arguments[0].id;
obj2=arguments[1].id;
document.all(Obj).setCapture()
pX=event.x-document.all(Obj).style.pixelLeft;
pY=event.y-document.all(Obj).style.pixelTop;
pX2=event.x-document.all(obj2).style.pixelLeft;
pY2=event.y-document.all(obj2).style.pixelTop;
}
function MMove(){
if(event.button==2) {
if(Obj!=''){
document.all(Obj).style.left=event.x-pX;
document.all(Obj).style.top=event.y-pY;
document.all(obj2).style.left=event.x-pX2;
document.all(obj2).style.top=event.y-pY2;
}
}
else{
return false;
}
}
function MUp(){
if(Obj!=''){
document.all(Obj).releaseCapture();
Obj='';
return false;
}
}
function drawRect(x1,y1,w,h){
document.getElementsByTagName("BODY")[0].innerHTML += '<div style="border:solid 3px #ff0000;z-index:5;position:absolute;top:'+ (y1-h/2) + 'px;left:' + (x1-w/2) + 'px;width:' + w + 'px;height:' + h +'px;" id="ice">&nbsp;</div>';
}
</script>
</head><body onLoad="drawRect(400,260,100,100)"><div id=diceng
style=position:absolute;left:100;top:100;width:100%;height:150;background:white;z-index:1>
<div style=position:absolute;left:0;top:0;width:40;height:150;background:white
onmousedown=MDown(diceng,ice)>
<img src="http://community.csdn.net/logo/Images/Message001.gif"width="200" height="200"></div>
</div></body>
</html>