I have a select box that calls window.open(url)
when an item is selected. Firefox will open the page in a new tab by default. However, I would like the page to open in a new window, not a new tab.
How can I accomplish this?
I have a select box that calls window.open(url)
when an item is selected. Firefox will open the page in a new tab by default. However, I would like the page to open in a new window, not a new tab.
How can I accomplish this?
You shouldn't need to. Allow the user to have whatever preferences they want.
Firefox does that by default because opening a page in a new window is annoying and a page should never be allowed to do so if that is not what is desired by the user. (Firefox does allow you to open tabs in a new window if you set it that way).
I may be wrong, but from what I understand, this is controlled by the user's browser preferences, and I do not believe that this can be overridden.
Give the window a 'specs' parameter with width/height. See here for all the possible options.
window.open(url, windowName, "height=200, width=200");
When you specify a width/height, it opens it in a new window instead of a tab.
No 5 answer worked for me in Firefox 3.5.5 12/9/2009 . Specify a window size and get a pop up new window, leave it blank and get a new tab.
You don't need to use height, just make sure you use _blank
, Without it, it opens in a new tab.
For a empty window:
window.open('', '_blank', 'toolbar=0,location=0,menubar=0');
For a specific URL:
window.open('http://www.google.com', '_blank', 'toolbar=0,location=0,menubar=0');
I wanted to open the window in new tab or new window in FF and bring the focus back on main window. Somehow window.focus() or window,blur does not seem to work
I know this is a relatively old question, but I want to point out that the accepted answer doesn't work on my browser (I'm not complaining, by the way, I myself wouldn't want that to work in my browser). I'm using Firefox 3.6, and have modified a number of about:config entries regarding opening in new windows (I don't want a website opening up a non-resizable window, for example). I don't know which part of this configuration makes the hack not work, so future readers will have to play around with it.
I find it so obnoxious and ignorant when people respond to a thread asking how to do something with, "don't," talking about how they wouldn't want that to work. Nobody asked for your lame, narrow minded opinion on whether the functionality is good or not.
There are many valid reasons for wanting this function. Look at Peter Horvath's brilliant work, Intervals. Oh, but you have to look at it on Safari, precisely because of this type of issue.
So I have this same issue, and the whole Blank and size specs are not the solution because I was already including them, and they don't override the tab thing.
What I should have is a new window that opens at a specific size so that when people click on a video link the video pops up in its own little appropriately sized window above the main page, but instead, the page pops up as a new tab and re-sizes all the other tabs to match it, super annoying.
I also tried adding in the modal=yes,alwaysRaised=yes" segment with no luck. Here is the code I am using that is not working. It has a combination of all the suggestions on here so none of them seem to work. I also tried pulling out segments to try alone with no luck. Some of the code may be seems redundant, but I am using this on a page that is within an iframe so when I remove the extra blank or returnfalse on the outside of the window open than it reverts to opening in the iframe. I have been testing the original page outside of its iframe though so the iframe isn't at fault.
Here is my unsuccessful attempt. Any suggestions are appreciated. This is after cobbling together extra bits from the suggestions in the thread.
Originally I was using the following: