Javascript examples for DOM:Event
The isTrusted event property tells if the event is triggered by the user or by a script.
A Boolean, indicating whether the event is trusted
The following code shows how to find out if a specific event is trusted:
<!DOCTYPE html> <html> <body> <button id="myBtn" onclick="myFunction(event)">Test</button> <button onclick="triggerClick()">Test</button> <script> 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"); btn.click(); } </script> </body> </html>