时间:2021-07-01 10:21:17 帮助过:5人阅读
<html>
<head>
<title>Dom:hasFocus方法实例</title>
</head>
<body onfocus="getFocus()" onblur="Empty_Focus()">
<h2>请点击网页区域.表明该网页获得焦点,显示为true.点击浏览器地址栏.该网页失去焦点显示为false</h2>
<hr/>
<a href="//www.gxlcms.com" onfocus="getFocus()">脚本之家</a>
<span id="c"></span>
<script language="javascript">
function getFocus(){
document.getElementById("c").innerHTML = document.hasFocus();
}
function Empty_Focus(){
document.getElementById("c").innerHTML = document.hasFocus();
}
</script>
</body>
</html>