I use window.open
and call it at the document ready
event, but it is blocked by a popup blocker in Firefox. Then I added this to the function and make a call of this function from a button and then trigger the button click without success:
$(function(){
abcd();
});
function abcd(){
var popup = window.open("http://localhost/johndyer-mediaelement-7ed6c51/demo/index.php","mypopup","width=500,height=300");
}
Is there some way to open an external popup window or new tab on browser when the page loaded?
I use window.open
and call it at the document ready
event, but it is blocked by a popup blocker in Firefox. Then I added this to the function and make a call of this function from a button and then trigger the button click without success:
$(function(){
abcd();
});
function abcd(){
var popup = window.open("http://localhost/johndyer-mediaelement-7ed6c51/demo/index.php","mypopup","width=500,height=300");
}
Is there some way to open an external popup window or new tab on browser when the page loaded?
Share Improve this question edited Oct 8, 2013 at 19:45 Peter Mortensen 31.6k22 gold badges110 silver badges133 bronze badges asked May 6, 2012 at 15:09 Suneth KalharaSuneth Kalhara 1,2085 gold badges18 silver badges43 bronze badges 1 |2 Answers
Reset to default 11Firefox 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/
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.
about:config
and search forpopup
to see why. I am not completely sure, yet, what this settings really do and how to enable unlimited popups for certain applications which need them. – Tino Commented Dec 18, 2012 at 21:11