87,910
社区成员
发帖
与我相关
我的任务
分享
<html lang="utf-8" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<style>
</style>
</head>
<script language="JavaScript">
function $(id){
return (document.getElementById(id));
}
function test(evt){
if(!$('div1')||$('div1').style.display=='none'){
return;
}
var e = window.event || e;
var o = e.srcElement || e.target;
while (o) {
if (o == $("div1")) {
return;
}
o = o.parentNode;
}
// alert("hi! you should close the div1!")
$('div1').style.display='none';
}
window.onload = function(){
document.onblur = document.onmousedown = document.onkeyup = test;
}
</script>
<body>
<input type="button" value="show div" onclick="$('div1').style.display='block';"><br>
<input type="text" value=""><br>
<input type="text" value=""><br>
<div id="div1" align="center" style="background:blue;position:absolute;left:300px;top:200px;width:300px;height:200px;overflow:auto;display:none;">
<br>
<p>
测试一下<input type="text" vlaue="">
<br>
测试一下<input type="text" vlaue="">
<br>
</p>
</div>
</body>
</html>