'window.open' blocked by Firefox

北城以北 提交于 2019-12-01 16:36:33
Click Upvote

Don't open pop up advertising. It's annoying.

On the other hand, if it's a message the user wants to see, then you can use a jQuery plugin like Colorbox to display a hovering modal window without opening a new popup, that the user can easily close.

Firefox has a bunch of rules that helps it to decide whether popup should be blocked or not. Usually if action is initialized with user click, firefox will allow opening popup, but if it's done by "pure" javascript it will most likely block it.

You can read about it in here: http://support.mozilla.org/en-US/kb/Pop-up%20blocker.

So if you read article carefully you will notice that popups initialized by user click will open:

<input type="button" value="Click Me"/>

and jquery code

$('input').click(function(){window.open("http://google.com");​​​​})​

even with popup blocker turned on. Try it:

http://jsfiddle.net/demee/mQ9eR/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!