isTrusted Event Property
Esempio
Scopri se un evento specifico è attendibile:
function myFunction(event) {
if ("isTrusted" in event) {
if (event.isTrusted) {
alert ("The " + event.type + " event is trusted.");
} else {
alert ("The " + event.type + " event is not trusted.");
}
} else {
alert ("The isTrusted property is not supported by your browser");
}
}
Definizione e utilizzo
La proprietà dell'evento isTrusted restituisce un valore booleano che indica se l'evento è attendibile o meno.
Nota: in Chrome, Firefox e Opera, l'evento è attendibile se viene richiamato dall'utente e non attendibile se viene richiamato da uno script. In IE, tutti gli eventi sono attendibili tranne quelli creati con il metodo createEvent().
Supporto browser
I numeri nella tabella specificano la prima versione del browser che supporta completamente la proprietà.
Property | |||||
---|---|---|---|---|---|
isTrusted | 46.0 | 9.0 | Yes | Not supported | 33.0 |
Sintassi
event.isTrusted
Dettagli tecnici
Valore di ritorno: | Un valore booleano, che indica se l'evento è attendibile o meno
Possibili valori:
|
---|---|
Versione DOM: | Eventi DOM di livello 3 |