javascriptpaypalpopup-blocker

How can I test if a named window is opened or was blocked by a popup blocker?


I'm opening a window (actually PayPal is) in javascript with the following code:

win = window.open('', this.name, 'top=' + top + ', left=' + left + 
  ', width=' + width + ', height=' + height + 
  ', location=0, status=0, toolbar=0, menubar=0, resizable=0, scrollbars=1');

If Chrome's popup blocker stops the creation of the window, I'd like to be able to detect that and alert the user. Is there some sort of test I can run on win to see if it actually ever opened?


Solution

  • As described in Window.open():

    How can I tell when my window was blocked by a popup blocker?

    With the built-in popup blockers of Mozilla/Firefox and Internet Explorer 6 SP2, you have to check the return value of window.open(): it will be null if the window wasn't allowed to open. However, for most other popup blockers, there is no reliable way.

    So, if the return value of window.open is null or undefined this means the window is blocked.