这段代码 是从版主哪里得到了 然后我自己修改成这样了 但是不知道为什么mou函数没有被执行到
分不多 求高手帮帮忙 解答一下 谢谢了
<a onmouseOver="mouse(event,1)" onmouseout="mouse(event,1)">a</a>  
<script type="text/javascript">      
function mouse(e,r){ 
if (e.type  == 'mouseover'){var a=0;
function move(){a++;
mou(e.type,r);//这里不是有循环调用到mou函数了吗 为什么下面的mou()没显示
if(a==5){clearInterval(time);}}
window.setInterval(move,2000);}   
else
alert("鼠标移出");
}
function mou(e,r){//这里不是有了吗 为什么不执行
if(r==5){
alert("事件已经触发"+e+r);}
}
</script>

解决方案 »

  1.   

    <a onmouseOver="mouse(event,1)" onmouseout="mouse(event,1)">a</a>  
    <script type="text/javascript">      
    function mouse(e,r){ 
      if (e.type  == 'mouseover'){
        var a=0,type=e.type;//要保存事件的type属性,不能在计时器中传递事件对象,事件对象只能用再当前发生的场景中,如果要使用事件的相关属性,要保存起来,而不是直接传递事件变量
        function move(){
          a++;
          mou(type,a);//这里应该是传递a,不是传递r吧。
          if(a==5){clearInterval(time);}//time没有申明,出错 了
        }
        time=window.setInterval(move,2000);///这样,得到time变量
      }   
     else
       alert("鼠标移出");
    }
    function mou(e,r){//r是mouse传递的参数,为1,1不等于5当然不执行alert事件了,应该是你传递错了吧,应该是传递a  if(r==5){alert("事件已经触发"+e+r);}
    }
    </script>
      

  2.   

    function mouse(e,r){ 
      if (e.type  == 'mouseover'){
        var a=0,type=e.type;//要保存事件的type属性,不能在计时器中传递事件对象,事件对象只能用再当前发生的场景中,如果要使用事件的相关属性,要保存起来,而不是直接传递事件变量
        function move(){
          a++;
          mou(type,a);//这里应该是传递a,不是传递r吧。
          if(a==5){clearInterval(time);}//time没有申明,出错 了
        }
        time=window.setInterval(move,2000);///这样,得到time变量
      }   
     else
       alert("鼠标移出");
    }
    function mou(e,r){//r是mouse传递的参数,为1,1不等于5当然不执行alert事件了,应该是你传递错了吧,应该是传递a  if(r==5){alert("事件已经触发"+e+r);}
    }
      

  3.   

    <script type="text/javascript">      
    function mouse(e,r){ 
    if(e.type  == 'mouseover'){
    var a=0;
    alert("in");
    function move(){
    a++;
    mou(e.type,a);
    //这里不是有循环调用到mou函数了吗 为什么下面的mou()没显示
    if(a==5){
    clearInterval(time);
    }
    }
    var time = window.setInterval(move,2000);
    }else{
    alert("out");
    }
    }
    function mou(e,r){
    //这里不是有了吗 为什么不执行
    alert("mou="+r);
    if(r==5){
    alert("事件已经触发"+e+r);
    }
    }</script>不好意思,之前看错了,没有少括号。
    注意一下红颜色字体,这样改动,是不是你要的结果。
      

  4.   

    <script type="text/javascript">      
    function mouse(e,r){ 
    if(e.type  == 'mouseover'){
    var a=0;
    alert("in");
    function move(){
    a++;
    mou(e.type,a);
    //这里不是有循环调用到mou函数了吗 为什么下面的mou()没显示
    if(a==5){
    clearInterval(time);
    }
    }
    var time = window.setInterval(move,2000);
    }else{
    alert("out");
    }
    }
    function mou(e,r){
    //这里不是有了吗 为什么不执行
    alert("mou="+r);
    if(r==5){
    alert("事件已经触发"+e+r);
    }
    }</script>
      

  5.   

    <script type="text/javascript">      
    function mouse(e,r){ 
    if(e.type  == 'mouseover'){
    var a=0;
    alert("in");
    function move(){
    a++;
    mou(e.type,a);//这里
    //这里不是有循环调用到mou函数了吗 为什么下面的mou()没显示
    if(a==5){
    clearInterval(time);
    }
    }
    var time = window.setInterval(move,2000);//这里
    }else{
    alert("out");
    }
    }
    function mou(e,r){
    //这里不是有了吗 为什么不执行
    alert("mou="+r);
    if(r==5){
    alert("事件已经触发"+e+r);
    }
    }</script>不知道怎么改字体颜色,唉