您的位置:首页 > Web前端 > JavaScript

js setTimeout实现延迟关闭弹出层

2010-04-01 00:00 706 查看
#flyout
{
border: solid 2px Gray;
background-color: #FFF999;
width: 300px;
height: 100px;
display: none;
}


var flyoutTimer;
function mouseOutEvent() {
//Hide flyout after 1 second when the mouse move out of the flyout zone
flyoutTimer = setTimeout(hideFlyout, 1000);
}
function mouseOverEvent() {
//Clear the timer when the mouse move over the flyout
clearTimeout(flyoutTimer);
}
function hideFlyout() {
document.getElementById("flyout").style.display = "none";
}
function showFlyout() {
document.getElementById("flyout").style.display = "block";
mouseOutEvent();
}





Click me to show flyout

This is a flyout





[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: