Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.open not opening window

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?

like image 578
StudioTime Avatar asked Apr 09 '26 19:04

StudioTime


2 Answers

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:

http://jsfiddle.net/DvMy5/2/

like image 53
Alex Avatar answered Apr 12 '26 07:04

Alex


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.

like image 33
megyewodi Avatar answered Apr 12 '26 08:04

megyewodi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!