views:

181

answers:

2

I found that, browsers don't block all pop-up JavaScript windows.

How to write pop-up windows in JavaScript that won't be blocked by browsers?

I mean what is the main factor that makes the difference?

+4  A: 

In Firefox (and most other modern web browsers with popup blockers) Javascript windows are typically allowed if they are the result of a user click, but stopped if they are trying to open in the background.

Compare the method used in these bad popups with these good popups. Source code is available on the site. Here is the source code for the "good" popups:

<a href="javascript:winopen('http://www.popuptest.com/popup3.html','blank','width=450,height=235,status=yes')"&gt;Good PopUp #1</a>
<br><br>
<A class=blu HREF="http://www.popuptest.com/popup2.html" target="_BLANK">Good PopUp #2</A>
<br><br>
<A class=black HREF="http://www.popuptest.com/popup3.html" onclick="NewWindow(this.href,'rank','450','450','yes','center');return false" onfocus="this.blur()">Good PopUp #3</A>
<br><br>
<a href="javascript:PopWindow('http://www.popuptest.com/popup4.html', 450, 320)">Good PopUp #4</A>
Mark Byers
Only two of those popup links looks remotely good, the rest are inaccessible.
Eli Grey
+3  A: 

The main factor for deciding what popup window will be blocked is the good pop-up window must be show after user do some action like click or do some other event like press enter.

However, you can use in-page pop-up window like JQuery UI Dialog that all pop-up blocker cannot block it because it just is html tag like span or div. Therefore, it does not clever enough for understanding content inside pop-up tag. It should be the best way to avoid all pop-up blockers.

Soul_Master