事件(记录)

<!doctype html>
<html>
<head>
<style>
.box
{background:red;padding:5px 0;height:25px}
#pop
{height:100px;width:400px;background:orange}
</style>
</head>

<body id="body">

<div id="box" class="box">
<a href="">目标</a>
</div>
<div id="pop" style="display:none"></div>

<script type="text/javascript">
var $ = function(id){return document.getElementById(id)}

function aa(elem1,elem2){
var elem = elem2.getElementsByTagName("*");
for(var i=0; i<elem.length; i++){
if(elem1 == elem[i]){
return true;
}
}
return false;
}
$(
"box").onmouseover = function(e){
var e = e || window.event;
var related = e.relatedTarget || e.formElement;
if(related != this && !aa(related,this)){
$(
"pop").style.display = "block";
}
}
$(
"box").onmouseout = function(e){

var e = e || window.event;
var related = e.relatedTarget || e.toElement;
if(related != this && !aa(related,this)){
$(
"pop").style.display = "none";
}
}
</script>

</body>
</html>

 

posted @ 2011-12-27 13:49  深蓝色梦想  阅读(189)  评论(0编辑  收藏  举报