Window.Open without popup-blocker

Abbas picture Abbas · Sep 27, 2012 · Viewed 9.9k times · Source

i want to open a popup window when user leaves tab or closes browser, the available option with me was window.open, but with that, it asks for popup blocker, if it is not enabled, i tried every possible ways to ignore popup-blocker but in vain, i tried onunload, onbeforeunload, but it does not works, i also tried to use modal dialog, before the tab/browser, i used it in onbeforeunload event, but it shows a browsers alert message, which i dont want, my simple requirement is, i need a popup window (if possible) or modal dialog, on the close of tab/browser, but should ignore popup-blocker, i guess with modal dialog, i dont need to worry about popup-blocker, because that wont be the new window, but how i would be handling it, while user closes tab/browser. If any of the above option is not possible, can anyone help me with any other possible alternative, or helpful articles.

Edited Question
i used the below script and with that i can open a new popup window on link click, without popup-blocker interfering in it

$('a[href=http://www.google.com]').click(function(){
    window.open(this.href);
    return false;
  });

then why its not possible for the closing events.

Answer

Dai picture Dai · Sep 27, 2012

You can't - because that's what popup blockers do: they block popup windows (i.e. calls to window.open or invocations of target="_blank" links) unless it is directly in response to a user mouse action.

Opening popups when a browser window is closed was a common tactic of "pop-under" ads in the early 2000s, and it irritated users, that's why Firefox and IE6's popup blocker block them, and there is no way around it for you unless you ask the user to disable their popup blocker on your site (and I think you'll find most of them will have no idea how to do that).

What are you trying to accomplish anyway? What is the content of this popup that you want the user to see? What other approaches have you tried?