HTML DOM hasFocus() Method

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP







<!--
main_leaderboard, all: [728,90][970,90][320,50][468,60]
-->




HTML DOM hasFocus() Method


❮ Document Object




Example


Output some text if the document has focus:



var x = document.getElementById("demo");
if (document.hasFocus())
  x.innerHTML = "The document has focus.";
else
  x.innerHTML = "The document DOES NOT have focus.";

Try it Yourself »


Definition and Usage


The hasFocus() method returns a Boolean value indicating whether the document
(or any element inside the document) has focus.



Browser Support


The numbers in the table specify the first browser version that fully supports the method.














Method
hasFocus() 30.0 6.0 3.0 Yes 23.0

Syntax




document.hasFocus()


Parameters



None

Technical Details




Return Value: A Boolean value, incidating whether the document or any element in the document has focus:

  • true - The document has focus

  • false - The document does not have focus


❮ Document Object


Popular posts from this blog

Malaysia to Papua New Guinea by motorcycle?

List of Bhojpuri films

PHP code is not being executed, instead code shows on the page