Detect a blocked pop-up window

Since reliable info doesn’t seem to be out there, this Javascript detects if a pop-up window was blocked at least by IE6/XPsp2’s built-in blocker, FF or Opera 8.

var popWin; // global for easy reference later
function pop(url, name, features, replace) {
    popWin = open(url, name, features, replace);
    if (popWin == null) { // nice blocking browsers return null
        alert('window blocked, redirect or whatever');
    } else {
        setTimeout(function() {
            if (typeof popWin.parent == 'undefined') { // opera
                alert('window blocked, redirect or whatever');
            }
        }, 200);
    }
}

How about Safari?

One thought on “Detect a blocked pop-up window

  1. tali mor says:

    i cant red the comment and he sad “a pop-up window was blocked”
    what i need do the i can do read?
    tank – you vwey mush.
    tali mor

Leave a Reply