Documento HTML DOM hasFocus()
Esempio
Visualizza se il documento ha lo stato attivo:
if (document.hasFocus()) {
text = "The document has focus.";
} else {
text = "The document does NOT have focus.";
}
Definizione e utilizzo
Il hasFocus()
metodo restituisce a true
se il documento (o qualsiasi elemento nel documento) ha lo stato attivo.
Altrimenti ritorna false
.
Sintassi
document.hasFocus()
Parametri
NONE |
Valore di ritorno
Tipo | Descrizione |
booleano | true se il documento (o un elemento nel documento) ha lo stato attivo. Altrimenti false . |
Supporto browser
document.hasFocus()
è supportato in tutti i browser:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |