English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Metodo hasFocus() HTML DOM

Oggetto Documento HTML DOM

hasFocus()Il metodo restituisce un valore booleano utilizzato per determinare se il documento (o qualsiasi elemento all'interno del documento) ha il focus.

Sintassi:

document.hasFocus()
var x = document.getElementById("para");
if (document.hasFocus()) {
x.innerHTML = "Il documento ha il focus.";
} else {
x.innerHTML = "Il documento non ha il focus.";
}
Prova a vedere‹/›

Compatibilità del browser

I numeri nella tabella specificano la versione del browser che supporta per la prima volta il metodo hasFocus():

Metodo
hasFocus()3036

Dettagli tecnici

Valore di ritorno:Se l'elemento attivo del documento non ha il focus, restituisce false; se l'elemento attivo del documento ha il focus, restituisce true

Oggetto Documento HTML DOM