Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

90
Views
Is it possible to differentiate between a button click triggered by a mouse click and a click triggered by the user's javascript?

Given a button reference, you can use javascript on your console to .click() it.

Is there a way for my website to differentiate between a click triggered by a mouse and a click triggered by the user's javascript? Or are these effectively equivalent from the browser's point of view?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use Event.isTrusted

Yes, you can use the event.isTrusted property. Will be true when the user clicks as shown in this code snippet.

mybutton.addEventListener("click", function(e) {
    console.log( "isTrusted = " + e.isTrusted );
});

test.addEventListener("click", function(e) {

  mybutton.click();

});
<button id="mybutton">My Button</button>

<button id="test">Test</button>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!