isTrusted Event Property - Javascript DOM

Javascript examples for DOM:Event


The isTrusted event property tells if the event is triggered by the user or by a script.

Return Value

A Boolean, indicating whether the event is trusted

The following code shows how to find out if a specific event is trusted:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button id="myBtn" onclick="myFunction(event)">Test</button>

<button onclick="triggerClick()">Test</button>

function myFunction(event) {/*from  w  w  w  . ja v  a 2  s.  c  om*/
        if (event.isTrusted) {
            console.log("The " + event.type + " event is trusted.");
        } else {
            console.log("The " + event.type + " event is not trusted.");

function triggerClick() {
    var btn = document.getElementById("myBtn");;


Related Tutorials