Question:
The question is – is it possible to do this with any hacks?
I have users select a list of links and on click they should open at once in new tabs.
I've been searching for a few days now. Tried creating links by js, window.open(), fake clicks, attributes, 2 libs and nothing…
And of course, this means bypassing pop-up blockers.
Thank you.
Answer:
window.open()
requires the following conditions:
- The stack
trace
must contain the trusted event. Formally, a click is not necessarily needed to trigger such an event, the samemousemove
gives a trusted event no worse thanclick
.
document.querySelector('button').onclick = event=>console.log(event.isTrusted);
document.querySelector('button').onmousemove = event=>console.log(event.isTrusted);
<button>Click me</button>
- There is one of two things: either the browser has a voluntarily manually set permission for pop-up windows by the user. Either
allow-popups
orunsave-none
will be passed among theCross-Origin-Opener-Policy
headers. Examples can be taken from here . If the server belongs to you, then this should not be a problem.