日期:2014-05-16 浏览次数:20375 次
<html>
<head>
<style>
a{
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>
<a id="moveMe" href = "http://www.baidu.com" >百度</a>
</body>
</html>