<html>
<script>
//鼠标按下事件
document.οnmοusedοwn=function()
{
document.body.innerHTML="X:"+event.x+",Y"+event.y;
}
//鼠标移动事件
document.οnmοusemοve=function()
{
document.body.innerHTML="onmousemove";
}
//鼠标松开
document.οnmοuseup=function()
{
document.body.innerHTML="onmouseup";
}
</script>
<body>
</body>
</html>
<html>
<title>
</title>
<script>
//鼠标按下事件
document.οnmοusedοwn=function()
{
document.getElementById("div1").innerHTML="X:"+event.x+",Y"+event.y;
}
//鼠标移动事件
document.οnmοusemοve=function()
{
document.getElementById("div2").innerHTML="X:"+event.x+",Y"+event.y;
}
//鼠标松开
document.οnmοuseup=function()
{
document.getElementById("div3").innerHTML="X:"+event.x+",Y"+event.y;
}
var run_length=10;
function run_func()
{
var odiv=document.getElementById("div4");
odiv.style.left=odiv.offsetLeft+run_length;
if(odiv.offsetLeft>=800||odiv.offsetLeft<=50)
{
run_length=run_length*(-1);
}
}
window.οnlοad=function()
{
setInterval(function(){run_func();},30);
}
var obj=null;
function down_func(a)
{
obj=a;
ox=event.x;
oy=event.y;
}
document.οnmοusemοve=function()
{
if(obj!=null)
{
obj.style.left=obj.offsetLeft+(event.x-ox);
obj.style.top=obj.offsetTop+(event.y-oy);
ox=event.x;
oy=event.y;
}
}
document.οnmοuseup=function()
{
obj=null;
}
</script>
<body>
<div style="background-color:gray;width:200px;height:100px;overflow:auto;" id="div1"></div>
<div style="background-color:green;width:200px;height:100px;overflow:auto;" id="div2"></div>
<div style="background-color:orange;width:200px;height:100px;overflow:auto;" id="div3"></div>
<div style="background-color:yellow;width:200px;height:100px;overflow:auto;position:absolute;top:300px;left:50px;" id="div4"></div>
<div style="background-color:red;width:50px;height:50px;overflow:auto;position:absolute;top:300px;left:50px;" id="div5" οnmοusedοwn="down_func(this);"></div>
</body>
</html>