<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>延時彈出層控制</title>
<script type="text/javascript">
var isPopLayer = false;
var time = null;
//打開彈出層
function poplay(){
if(!isPopLayer){
//延遲1秒顯示層
time = setTimeout(function(){
document.getElementById('poplay').style.display = 'block';
clplay();
isPopLayer = true;
}, 1000);
}
}
//鼠標移走時執行
function clplay(){
clearTimeout(time);
time = null;
}
//關閉彈出層
function poclose(){
document.getElementById('poplay').style.display = 'none';
isPopLayer = false;
}
</script>
<style type="text/css">
#poplay{ padding:1em; position:absolute; border: 3px solid #000; display:none;}
</style>
</head>
<body>
<a href="#" onmouseover="poplay()" onmouseout="clplay()">文字1</a> 這個
<a href="#" onmouseover="poplay()" onmouseout="clplay()">文字2</a> 這個
<a href="#" onmouseover="poplay()" onmouseout="clplay()">文字3</a> 這個
<div id="poplay">
<p>彈出層的內容</p>
<p>彈出層的內容</p>
<p>彈出層的內容</p>
<p>彈出層的內容</p>
<button onclick="poclose()">關閉</button>
</div>
</body>
</html></td>
</tr>
</table>