English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
hasFocus()The method returns a boolean value that is used to detect whether the document (or any element within the document) has focus.
document.hasFocus()
var x = document.getElementById("para"); if (document.hasFocus()) { x.innerHTML = "The document has focus."; } x.innerHTML = "The document does not have focus."; }Test See‹/›
The numbers in the table specify the first browser version that fully supports the hasFocus() method:
Method | |||||
hasFocus() | 30 | 3 | Yes | Yes | 6 |
Return value: | Returns false if the active element in the document does not have focus; returns true if the active element in the document has focus. |
---|