Why window.open is not blocked on setTimeout <= 1000 ms?

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?

+4
source share
1 answer

From HTML 5.2 :

, :

...

...

... , , .

onclick , setTimeout ( ), .

.

+1

Source: https://habr.com/ru/post/1693634/


All Articles