如何让定时器不停来,用SetTimeOut()来做,右键的时候定时器就停下来了要怎么让停时器不停下来

解决方案 »

  1.   


    <html>
    <body>
    <script type="text/javascript">
    var i = 0; timer = null;
    function setTime() {
    document.getElementById("ospan").innerHTML = ++i;
    timer = setTimeout(arguments.callee, 1000);
    }
    window.onload = function(){
    setTime();
    }document.onmousedown = function(e){
    var e = e || window.event;
    ((e || window.event).button == 2) && clearTimeout(timer);
    }
    </script>
    <span id="ospan"></span>
    </body>
    </html>
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head><body>
    <span id="ss">aa</span>
    </body>
    <script language="javascript">
    var c=0;
    function ff(){
    c=c+1;
    document.getElementById("ss").innerHTML=c;
    setTimeout("ff()",1000);
    }
    setTimeout("ff()",1000);
    </script>
    </html>
    像上面的代码,点鼠标右键,定时器就停下来了 @_@
    会不会无解
      

  3.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head><body>
    <span id="ss">aa</span>
    </body>
    <script language="javascript">
    var c=0;
    var timer = null;
    function ff(){
        c=c+1;
        document.getElementById("ss").innerHTML=c;
        timer =  setTimeout("ff()",1000);
    }document.onmousedown = function(e){
        var e = e || window.event;
        ((e || window.event).button == 2) && clearTimeout(timer);
    }setTimeout("ff()",1000);
    </script>
    </html>
      

  4.   


    document.oncontextmenu = function(){
    return false;
    }// 把右键禁了吧