<html>
<head>
<style>
img
{
position:relative;
}
</style>
<script type="text/javascript">
mouseover=true
function coordinates()
{
if (!moveMe)
{
return
}
if (event.srcElement.id=="moveMe")
{
mouseover=true
pleft=document.getElementById('moveMe').style.pixelLeft
ptop=document.getElementById('moveMe').style.pixelTop
xcoor=event.clientX
ycoor=event.clientY
document.onmousemove=moveImage
}
}
function moveImage()
{
if (mouseover&&event.button==1)
{
document.getElementById('moveMe').style.pixelLeft=pleft+event.clientX-xcoor
document.getElementById('moveMe').style.pixelTop=ptop+event.clientY-ycoor
return false
}
}
function mouseup()
{
mouseover=false
}
document.onmousedown=coordinates
document.onmouseup=mouseup
</script>
</head>
<body>
<img id="moveMe" src="/i/eg_smile.gif" /><br />
<b>请拖动这幅图像。</b>
</body>
</html>