如何用js语言写
在界面没有操作后的30秒执行一个函数
鼠标只要移动或者点击就取消计时   操作完之后又进入计时30秒求教

解决方案 »

  1.   

    settimeout和setInterval去看看这2个方法。。
      

  2.   

    settimeout("执行代码",设定时间),用这个
      

  3.   

    这需要你自己onmouseover和onclick写方法在里面写让计时器停止。。网上这样的例子很多的。。
      

  4.   

    只使用了onmousemove事件,其他请自行添加
    (function(){ 
      var listen=function(){
        document.getElementsByTagName('body')[0].style.background='gray';
      };
      var timing=setInterval(listen,5000);
      
      document.onmousemove=function(){
        document.getElementsByTagName('body')[0].style.background='';
        clearInterval(timing);
        timing=setInterval(listen,5000);
      };
    })();
      

  5.   

     在js定义一个全局变量var a=30m, 使用这个函数settimeout("执行代码",a),  当鼠标移动或点击事件触发后就把变量a设为30秒;
      

  6.   

    onmouseover,加上这个,就能做到了
      

  7.   

    在html中写这个,加入标签<onmouseover="mover(this)">var timeid = setTimeout("code","time");//开始计时
    function mover(object){//当鼠标俩开你需要的位置的时候,计时停止clearTimeout(timeid);
    }