<body onmousemove="window.status = 'X=' + window.event.x + ' Y=' + window.event.y">在状态条上可以显示鼠标在窗口中的坐标值

解决方案 »

  1.   

    <HTML>
    <HEAD>
    <script>
    var s=0; //秒
    var x=0,y=0; //鼠标坐标1
    var xx=0,yy=0; //鼠标坐标2window.onload=e;
    document.onmousemove=ee;function e()
    {
        x=event.screenX ;
        y=event.screenY ;
        window.setInterval('check()',1000); //每秒检测一次
    }function check()
    {
        if(x==xx || y==yy)
        {
            info.innerHTML ="鼠标静止";
            s++; //秒递增
            if(s>=5) //如果达到或超过30秒.
            {
                alert('超时'); //你要执行你要的操作
            }
        }
        else
        {
            x=xx;
            y=yy;
            s=0; //秒记数清零
            info.innerHTML="鼠标在移动";
        }
    }function ee()
    {
        xx=event.screenX;
        yy=event.screenY;
    }
    </script>
    </HEAD>
    <BODY><span id=info></span>
    </BODY>
    </HTML>
      

  2.   

    简化版===============
    <HTML>
    <HEAD>
    <script>
    var s=0; //秒window.onload=e;
    document.onmousemove=ee;function e()
    {
        window.setInterval('check()',1000); //每秒检测一次
    }function check()
    {
        if(s>=5) //如果达到或超过30秒.
        {
            alert('超时'); //你要执行你要的操作
        }
        else
        {
            s++;
        }
    }function ee()
    {
        s=0;
    }
    </script>
    </HEAD>
    <BODY>
    </BODY>
    </HTML>
      

  3.   

    补充
    把if(s>=5) //如果达到或超过30秒.  =====>   if(s>=30) //如果达到或超过30秒.
    因为测试是我改成了5秒,贴代码时没改回来.
      

  4.   

    如swans(swan.net) ,不难吧!