Google Chrome "window.open" workaround?

190,413

Solution 1

The other answers are outdated. The behavior of Chrome for window.open depends on where it is called from. See also this topic.

When window.open is called from a handler that was triggered though a user action (e.g. onclick event), it will behave similar as <a target="_blank">, which by default opens in a new tab. However if window.open is called elsewhere, Chrome ignores other arguments and always opens a new window with a non-editable address bar.

This looks like some kind of security measure, although the rationale behind it is not completely clear.

Solution 2

This worked for me:

newwindow = window.open(url, "_blank", "resizable=yes, scrollbars=yes, titlebar=yes, width=800, height=900, top=10, left=10");

Solution 3

The location=1 part should enable an editable location bar.

As a side note, you can drop the language="javascript" attribute from your script as it is now deprecated.

update:

Setting the statusbar=1 to the correct parameter status=1 works for me

Solution 4

I believe currently there is no javascript way to force chrome to open as a new window in tab mode. A ticket has been submitted as in here Pop-ups to show as tab by default. But the user can click the chrome icon on the top left corner and select "Show as tab", the address bar then becomes editable.

A similar question asked in javascript open in a new window not tab.

Solution 5

menubar must no, or 0, for Google Chrome to open in new window instead of tab.

Share:
190,413
Paul
Author by

Paul

Designer, Front End Developer, WordPress Developer. 🥋Judoka. ⚽️Everton. 🏀Nets. 😔Substandard Bio Writer.

Updated on July 05, 2022

Comments

  • Paul
    Paul almost 2 years

    I have been working on a web app and for part of it I need to open a new window. I have this working on all browsers, my sticking point is with Google Chrome.

    Chrome seems to ignore the window features which is causing me issues, the thing I'm struggling with is I need the address bar to be editable within the new window. FF, IE, Safari and Opera do this fine, Chrome does not.

    My Code:

    function popitup(url) {
      newwindow=window.open(url, 'name', 'toolbar=1,scrollbars=1,location=1,statusbar=0,menubar=1,resizable=1,width=800,height=600');
      if (window.focus) {
        newwindow.focus()
      }
      return false;
    }