isTrusted Event Property

Example

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 »

Description

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.


Syntax

event.isTrusted

Technical Details

Return Value: A Boolean, indicating whether the event is trusted or not

Possible values:

  • true - The event is trusted
  • false - The event is not trusted
DOM Version: DOM Level 3 Events

Browser Support

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


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.