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.
An element with focus is always the active element in a document, but an active element does not necessarily have focus. For example, an active element within a window that is not the foreground window has no 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?
Supported by objects:
User Contributed Comments