<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<table width="50%" height="186" id=tb1>
<tr>
<td width="50%" ><br>
<div  onmouseout="disdiv1(this)" id="div0"  style='display=none;background-color:#DFE8F6; width:500; height:400' >
<a  href="mailto:[email protected]"><span style="color:#FF00BB; font:bold Arial, Helvetica, sans-serif ; font-size: 20px">[email protected] </span></a>

</div>

<span onMouseOver="div1(this)" id='span0' >
</span>

</a>


</td>
</tr>
</table>
<script language="JavaScript">
function div1(data)
{
document.getElementById('div0').style.display='block';

document.getElementById('div0').focus();
}

function disdiv1(data)
{

data.style.display='none';
}


</script>     
</body>
</html>问题:鼠标移动到层里的链接的时候怎么触发onmouseout了呢?哪出错了?

解决方案 »

  1.   

    阻止冒泡function stopBubble(e){
    //非ie的
    if(e&& e.stopPropagation)
    e.stopProgpagation();
    else
    window.event.cancelBubble=true;
    }
      

  2.   

    window.event为空或不是对象
      

  3.   

    HTML有问题吧?
       <span onMouseOver="div1(this)" id='span0' >
                    </span>
            
            </a>      
    这个/a是对应的哪个 a?  
        
      

  4.   


    <table width="50%" height="186" id=tb1>
            <tr>
                <td width="50%" ><br>        
            <div  onmouseout="disdiv1(event, this)" id="div0"  style='display=none;background-color:#DFE8F6; width:500; height:400' >            
            <a  href="mailto:[email protected]"><span style="color:#FF00BB; font:bold Arial, Helvetica, sans-serif ; font-size: 20px">[email protected] </span></a>
            
            </div>
            
            <span onMouseOver="div1(this)" id='span0' >
                    </span>
            
            </a>        
        
            
                    </td>
            </tr>                
    </table>
            <script language="JavaScript">         //兼容FF
             HTMLElement.prototype.contains = function(element) {
                    if (element == this) return true;
                    while (element = element.parentNode) if (element == this) return true;
                    return false;
                }        function div1(data)
            {                    
                    document.getElementById('div0').style.display='block';
                    
                    document.getElementById('div0').focus();        
            }
            
            function disdiv1(e, data)
            {
                e = e || window.event;
                var related = e.toElement ? e.toElement : e.relatedTarget;
                if(data.contains(related)) return;
                data.style.display='none';
            }
        
            
            </script>    
      

  5.   

    给你个例子,这个例子可以告诉你怎样防止事件的传递。
    <html>
    <head>
    <title>Event Propagation</title><style type="text/css">
     #t-daddy { border: 1px solid red }
     #c1 { background-color: pink; }
    </style><script type="text/javascript">function stopEvent(ev) {
      // this ought to keep t-daddy from getting the click.
      ev.stopPropagation();
      alert("be stop");
    }function load() {
      elem = document.getElementById("c1");
      elem.addEventListener("click", stopEvent, false);
    }
    </script>
    </head><body onload="load();"><table id="t-daddy" onclick="alert('not stop');">
     <tr id="tbl1">
      <td id="c1">one</td>
     </tr>
     <tr>
      <td id="c2">two</td>
     </tr>
    </table></body>
    </html>