I'm trying to open an anchor context menu using only JavaScript, eg for this HTML:
<html>
<head></head>
<body>
<a href="https://stackoverflow.com" id="anchor-el"> Anchor </a>
</body>
</html>
I want to open the context menu with the native 'Open in link new tab' and 'Open link in new window' options using just JavaScript.
So far I've tried this, and it seems to successfully dispatch a contextmenu
event to the anchor, but the context menu doesn't actually show...
document.getElementById('anchor-el').dispatchEvent(new MouseEvent('contextmenu', { bubbles: true }))