开发者

Blocked vs Non-blocked Pop-up window

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 t开发者_运维技巧he difference?


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')">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>


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜