首页 > 其他 > 详细

自己练习了一个弹出框

时间:2014-04-18 21:29:42      阅读:590      评论:0      收藏:0      [点我收藏+]

html

 

<ul class="head" id="head">
	<li>消息</li>

</ul>

<div id="footer">
<p>你购买的宝贝 有2个物流变</p>
<p>你的交易 有1个新通知</p>
</div>

  

css 

 

bubuko.com,布布扣
#footer {
    width: 200px;
    border: solid 1px #ccc;
    height: 50px;
    font-size: 13px;
    padding: 10px;
    position:absolute;
    top:40px;
    display:none;
}
.head li { width:100px; height:30px; background-color:#f4f4f4; line-height:30px; text-align:center;}
bubuko.com,布布扣

 

js 代码如下  

 

bubuko.com,布布扣
<script>
var list = document.getElementById("head").getElementsByTagName("li")[0];

listenEvent(list,"mouseover",show);
listenEvent(list,"mouseout",judge);

var foot = document.getElementById("footer");
var time ;
function show(){
    var isOut=true ;
    kongzhi(isOut);
}

function  judge (){
    var isOut=false  ;
    listenEvent(foot,"mouseover",function(){isOut=true;kongzhi (isOut)});
    listenEvent(foot,"mouseout",function(){isOut=false;kongzhi (isOut)});
    
    if(!isOut){kongzhi(isOut) };
}


function kongzhi (isOut){
    if(time){clearTimeout(time);}
    time = setTimeout(function (){ if(!isOut) {foot.style.display = ‘none‘}else {foot.style.display = "block"; }   },200) 
        
}    
// 侦听
function listenEvent(eventTarget,eventType,eventHandler){
    if(eventTarget.addEventListener){
        eventTarget.addEventListener(eventType,eventHandler)
        }
    else if (eventTarget.attachEvent){
        eventType = "on" +eventType ;
        eventTarget.attachEvent(eventType,eventHandler)
        }
    else {
        eventTarget["on"+eventType]=eventHandler;
        }
    }    
        
</script>
bubuko.com,布布扣

 

自己练习了一个弹出框,布布扣,bubuko.com

自己练习了一个弹出框

原文:http://www.cnblogs.com/xiaotian747/p/3670888.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!