hasFocus method (document)
Returns a Boolean value indicating whether the document or any element in the document has focus.
Note: The hasFocus method is supported in Firefox from version 3.The hasFocus method can be useful to determine whether the active element in a document has focus. Use the activeElement property to retrieve and the focus and setActive methods to set the active element in a document.
You can find the related objects in the Supported by objects section below.
Boolean. One of the following values:
|The active element in the document has no focus.|
|The active element in the document has focus.|
Example HTML code 1:
This example illustrates the use of the hasFocus method:
Did you find this example helpful?
User Contributed Comments