SoFunction
Updated on 2025-02-28

javascript hasFocus usage example


<html>
<head>
<title>Dom:hasFocus method example</title>
</head>
<body onfocus="getFocus()" onblur="Empty_Focus()">
<h2>Please click on the web page area. It indicates that the web page has gained focus and is displayed as true. Click on the browser address bar. The page loses focus and shows false</h2>
<hr/>
<a href="https://" onfocus="getFocus()">I</a>
<span ></span>
<script language="javascript">
function getFocus(){
("c").innerHTML = ();
}
function Empty_Focus(){
("c").innerHTML = ();
}
</script>
</body>
</html>