Dokument HTML DOM hasFocus()
Przykład
Wyświetl, jeśli dokument ma fokus:
if (document.hasFocus()) {
text = "The document has focus.";
} else {
text = "The document does NOT have focus.";
}
Definicja i użycie
Metoda hasFocus()
zwraca a true
, jeśli dokument (lub dowolny element w dokumencie) ma fokus.
W przeciwnym razie zwraca false
.
Składnia
document.hasFocus()
Parametry
NONE |
Wartość zwrotu
Rodzaj | Opis |
Boole'a | true czy dokument (lub element w dokumencie) ma fokus. W przeciwnym razie false . |
Obsługa przeglądarki
document.hasFocus()
jest obsługiwany we wszystkich przeglądarkach:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |