'Create Ctrl+click mouse event
I am trying to fire a mouse event that would mimic Browser's Ctrl+ mouseclick when clicking on a hyperlink to open a new tab but keep current tab selected. Here is my code:
var link = document.createElement('a');
link.href = 'URL';
document.body.appendChild(link);
link.dispatchEvent(new MouseEvent('click', {ctrlKey: true}))
It does open a new tab but also switches to it. Any chance to keep it on the currect tab?
Thanks
Solution 1:[1]
It's default behavior for the browser, you can't change this(
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Andrii Svirskyi |
