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

132
Views
how do I create a script which creates an alert when the user right-clicks on a specific image?

This is my first Javascript task and they want me to create this alert. The thing is I've tried using the on-click attribute, but it doesn't work when I right-click. help? also, do I need to disable the default context menu for this?

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

0

onContextMenu is the event you need

HTML

<img oncontextmenu="myFunction()" contextmenu="mymenu">

Javascript

function myFunction() {
  alert("You right-clicked the img");
}

External example can be found here https://www.w3schools.com/jsref/event_oncontextmenu.asp

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!