To detect if a browser is blocking a popup with JavaScript, we check various property of the window.
For instance, we write
const newWin = window.open(url);
if (!newWin || newWin.closed || typeof newWin.closed === "undefined") {
//...
}
to call window.open
to open url
in a new window.
Then if newWin
is undefined, or closed
is true
, or closed
is undefined, then the popup window is blocked.