<html>
<head>
<script language="JavaScript">
var currentobj = null;
function setobj(block){
currentobj = block;
}
function releseobj(block){
if(currentobj = block){
currentobj = null;
}
}
function move(event){
var xx = event.clientX;
var yy = event.clientY;
if(null != currentobj){
currentobj.style.left = (event.clientX-25)+"px";
currentobj.style.top = (event.clientY-25)+"px";
}
}
function change(){
var x = document.c_form.x.value;
var y = document.c_form.y.value;
var block = document.getElementById("block");
block.style.left=x+"px";
block.style.top=y+"px";
}
</script>
</head>
<body onMouseMove="move(event)" >
<form name="c_form">
<input type="text" name="x">
<input type="text" name="y"><br/>
<input type="button" value="改變位置" οnclick="change()">
</form>
<div id="block" onMouseUp="releseobj(this)" onMouseDown="setobj(this)" style="height:50px;width:50px;background-color:#FF0000;position:absolute;left:30px;top:80px">
</div>
<div id="block2" onMouseUp="releseobj(this)" onMouseDown="setobj(this)" style="height:50px;width:50px;background-color:#FF00ff;position:absolute;left:30px;top:80px">
</div>
<div id="block3" onMouseUp="releseobj(this)" onMouseDown="setobj(this)" style="height:50px;width:50px;background-color:#FFDDDD;position:absolute;left:30px;top:80px">
</div>
<div id="block4" onMouseUp="releseobj(this)" onMouseDown="setobj(this)" style="height:50px;width:50px;background-color:#ce2020;position:absolute;left:30px;top:80px">
</div>
<div id="block5" onMouseUp="releseobj(this)" onMouseDown="setobj(this)" style="height:50px;width:50px;background-color:#00ff00;position:absolute;left:30px;top:80px">
</div>
<div id="block6" onMouseUp="releseobj(this)" onMouseDown="setobj(this)" style="height:50px;width:50px;background-color:#00ffyf;position:absolute;left:30px;top:80px">
</div>
</body>
</html>