Guy Sopher
Guy Sopher

Reputation: 4462

window.open opens a new tab instead of a new window (in chrome)

I have a code that used to open a popup window in all browsers, but now chrome started opening a new tab instead.

Does anyone knows what did they change and how do I open a popup window now?

This is my code:

function openWindow(url, title) {
  window.open(url, title, 'height=640,width=960,toolbar=no,menubar=no,scrollbars=no,location=no,status=no');
}

Upvotes: 5

Views: 13487

Answers (5)

poisonck
poisonck

Reputation: 11

It might not be obvious, but for those who still needs the solution and that issue happens only on macOS, most probably it works as intended, but it is likely you are using the full screen mode on your Mac - and the link being opened in new tab, because due to some “expected” OS behavior the new window cannot be opened and showed while you are in full screen mode. Try to exit the full screen mode and that code should work fine opening the link in new window.

Upvotes: 1

Flak DiNenno
Flak DiNenno

Reputation: 2352

Generally / ALSO...

This seems to happen whenever you pass an invalid comma delimited "settings string" as your 3rd (settings) param, i.e. window.open(url, window_title, settings).

So, check your spelling, look for errors, make sure you haven't specified (passed in) incorrect/incompatible options in that string.

It seems when this happens the window.open() call will just ignore the whole OPEN IN A NEW WINDOW concept, and just opens the specified URL (as best it can retrieve it) in a new/next tab.

Upvotes: 0

node_modules
node_modules

Reputation: 4925

Could you try this code please?

function openWindow(url, title) {
    var myWindow = window.open(url, title, "height=640,width=960,toolbar=no,menubar=no,scrollbars=no,location=no,status=no");
}

Working example: https://jsfiddle.net/C0dekid/go96uk5r/5/

Upvotes: 2

Quentin Morrier
Quentin Morrier

Reputation: 735

This is working for me:

window.open('https://www.google.com', 'MyWindow1', "height=640,width=960,toolbar=no,menubar=no,scrollbars=no,location=no,status=no");

What is your Chrome version?

My version is 49.0.2623.87 m

Upvotes: 1

Zamboney
Zamboney

Reputation: 2010

i think the problem is in the second argument. check this. name - The name of the window (Note: the name does not specify the title of the new window)

Upvotes: 2

Related Questions