HTML DOM Document hasFocus() method
- Föregående sida getElementsByTagName()
- Nästa sida head
- Åter till föregående nivå HTML DOM Documents
Definition and usage
If the document (or any element within the document) has gained focus hasFocus()
The method returns true
.
Otherwise return false
.
Example
Show if the document has focus:
if (document.hasFocus()) { text = "The document has focus."; } else { text = "The document does NOT have focus."; }
Syntax
document.hasFocus()
Parameter
None.
Return value
Type | Description |
---|---|
Boolean value |
Returns true if the document (or any element within the document) has focus. Otherwise return false. |
Browser support
All web browsers support document.hasFocus()
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Stöd | Stöd | Stöd | Stöd | Stöd | Stöd |
- Föregående sida getElementsByTagName()
- Nästa sida head
- Åter till föregående nivå HTML DOM Documents