document.querySelector('#ontime').onclick = function() {
setTimeout(() => {
window.open('https://www.google.com');
}, 1000);
};
When using window.open after a user clicks with a timeout of <= 1000 ms (or Promise.resolve().then(...)), it is not blocked by the browser.
If you do the same using a timeout> 1000 ms or requestAnimationFrame, the popup is blocked.
A full four-case example is available at the link below:
https://jsfiddle.net/kouty79/rcwgbfxy/
Does anyone know why? Is there any documentation or w3c spec about this?
source
share