Find out if a specific event is trusted:
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");
}
}
Try it Yourself »
The isTrusted event property returns a Boolean value indicating whether the event is trusted or not.
Note: In Chrome, Firefox and Opera, the event is trusted if it is invoked by the user, and not trusted if it is invoked by a script. In IE, all events are trusted except those that are created with the createEvent() method.
event.isTrusted
Return Value: | A Boolean, indicating whether the event is trusted or not Possible values:
|
---|---|
DOM Version: | DOM Level 3 Events |
event.isTrusted
is a DOM Level 3 (2004) feature.
It is fully supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 11 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!