0

Currently, I have an image that has three buttons (all of which are part of the image itself) and I used image mapping to have those button link to another URL.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/map

Although it works as expected, I cannot figure out how to know what user has navigated if they right clicked and choose "Open new tab" in their browser.

Is there way in Javascript you can know what the new tab that opens will be directed to?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Alejandro
  • 2,266
  • 6
  • 35
  • 63
  • Add the `oncontextmenu` event listener to anchor tag elements, (https://stackoverflow.com/questions/4235426/how-can-i-capture-the-right-click-event-in-javascript), grab the elements `href` on the callback function of the event, store it as a variable or in database or whatever you want to do with it. – Ryan Wilson Apr 09 '19 at 23:55
  • Disabling contextmenu would be best approach if you must know. if user right clicks, there is no way to know if they follow through or not opening in new tab. If disabled they won't have the option available as right click won't give them the default menu – charlietfl Apr 10 '19 at 00:06

0 Answers0