2

I am adding an image inside a div. I want to get the coordinates of the image (and not the coordinates of the screen) at the point where the user right clicks over that image. How can i do that?

<div id="Boma" style="width: 1000px; height: 600px; position: relative">
  <img src="Boma_1_2/F16_20170316141116392_0001.jpg" alt="Boma" style="width: 1000px; height: 600px;">  
</div>
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Salman
  • 393
  • 1
  • 7
  • 23
  • 1
    http://jsbin.com/akiwo – Baptiste Aug 22 '17 at 12:48
  • Please take some time to read the help page, especially the sections named ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). And more importantly, please read [the Stack Overflow question checklist](http://meta.stackexchange.com/q/156810/204922). You might also want to learn about [Minimal, Complete, and Verifiable Examples](http://stackoverflow.com/help/mcve). – Rory McCrossan Aug 22 '17 at 13:01

1 Answers1

0

I recommend you to checkout the .offset() jQuery function:

The .offset() method allows us to retrieve the current position of an element (specifically its border box, which excludes margins) relative to the document.

Here is a pretty clear and usefull comment about using Right Click in Javascript.

And you should now have all the tools to create what you want to do. Hope it will help.

Louis 'LYRO' Dupont
  • 1,052
  • 4
  • 15
  • 35