I'm trying to open a page in a popup as opposed to new tab - but whichever browser I try this simply opens in a new tab, not popup.
<input type="button" value="new win" onclick="window.open('http://yahoo.com', 'width=500, height=400')" />
Any reason why?
-
I think that what you're facing is due to the fact that modern browsers are configured to open popups in new tabs...Matteo Tassinari– Matteo Tassinari2012年10月16日 10:32:35 +00:00Commented Oct 16, 2012 at 10:32
5 Answers 5
Second parameter must be the window name:
<input type="button" value="new win"
onclick="window.open('http://yahoo.com', 'mywindow', 'width=500, height=400')" />
Working fine in Chrome and Firefox:
1 Comment
The second parameter should be name..Something like windowname
<input type="button" value="new win"
onclick="window.open('http://yahoo.com','windowname', 'width=500, height=400')" />
Comments
onclick="window.open('http://yahoo.com', 'MyYahoo', 'width=500, height=400, toolbar=no, menubar=no')" />
window.open method is as follow.
window.open(URL,name,specs,replace)
Here is a good read Window open() Method
name Optional. Specifies the target attribute or the name of the window. The following values are supported:
_blank - URL is loaded into a new window. This is default
_parent - URL is loaded into the parent frame
_self - URL replaces the current page
_top - URL replaces any framesets that may be loaded
name - The name of the window
Comments
The problem is the 3rd argument to window.open. When you pass the 3rd argument, the browser will open a new window provided the window name(second argument is not already opened).
window.open("http://localhost:5000", "newWindow", "resizable")will open window but window.open("http://localhost:5000", "newWindow") will open a tab.
1 Comment
Isn't this something controlled by the various browsers? Using target="_blank" opens in a new tab in Chrome, and my guess is that this also apply for Firefox, Opera, Safari and IE.
1 Comment
<a /> elements.