我写了一个onmouseover事件,可我想当鼠标快速滑过的时候并不执行onmouseover事件,只有鼠标放上超过1秒再执行onmouseover事件应该怎么做?

解决方案 »

  1.   

    setTimeout(yourfunction,2*1000);function yourfunction(){
      alert();
    }
      

  2.   

    我用了settimeout可是为什么每隔2秒就执行一次呢?
      

  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>
    <title> by Bsing </title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <link href="images/css.css" type="text/css" rel="stylesheet">
    </head><body>
    <a href="javascript:;" onmouseover="initializeFun();setTimeout('waitFun()',1*1000);" onmouseout="exitFun();">test</a>
    <div id="al"></div>
    <script>
    var tmp = true;
    function waitFun()
    {
    if (tmp)
    {
    alert(tmp);
    }
    }
    function initializeFun(){ tmp =true; document.getElementById("al").innerHTML = "true"; }
    function exitFun(){ tmp = false; document.getElementById("al").innerHTML = "false"; }
    </script>
    </body>
    </html>
      

  4.   

    ps:可能不会一直跟中帖子,楼主如果有后续问题请pm.
      

  5.   

    PM就是发消息给他的意思,M我知道是MESSAGE,P是啥意思?
      

  6.   

    timerID = self.setTimeout('StartTheTimer()', delay);运行后再clearTimeout(timerID)
      

  7.   

    <SCRIPT LANGUAGE = "JavaScript">
    <!--
    var secs
    var timerID = null
    var timerRunning = false
    var delay = 1000function InitializeTimer()
    {
        // Set the length of the timer, in seconds
        secs = 10
        StopTheClock()
        StartTheTimer()
    }function StopTheClock()
    {
        if(timerRunning)
            clearTimeout(timerID)
        timerRunning = false
    }function StartTheTimer()
    {
        if (secs==0)
        {
            StopTheClock()
            // Here's where you put something useful that's
            // supposed to happen after the allotted time.
            // For example, you could display a message:
            alert("You have just wasted 10 seconds of your life.")
        }
        else
        {
            self.status = secs
            secs = secs - 1
            timerRunning = true
            timerID = self.setTimeout("StartTheTimer()", delay)
        }
    }
    //-->
    </SCRIPT>
      

  8.   

    <img id="img1" style="width: 36px"  src="Images/checked.png" onmouseover="a()"  onmouseout="bb();" />
    var timer = 3000;
        var x;
        function a()
        {
        x = setTimeout('aa()',timer);    }
        function aa()
        {
               form1.img1.src = 'Images/unchecked.png';
               window.clearInterval(x);
        }
        function bb()
        {
            window.clearTimeout(x);
            form1.img1.src = "Images/checked.png";
        }
      

  9.   

    晕 现在还没解决
    <div onmouseover='ffff'/>
    fff=function (){
    var s=setTimeout(function(){
     //do your work
     clearTimeout(s);
    },2*1000);
    }