2

I need to open a 'New Window' using JavaScript. The window must display the page in new window with a tab instead of a simple window.

window.open(
    "http://google.co.za", null,
    "toolbar=yes,titlebar=yes,status=yes,menubar=yes,fullscreen=yes,centerscreen=yes"
);

produces this window:

enter image description here

Instead, I'm wondering if it's possible to open new window with a tab inside: enter image description here

Dmitriy Kravchuk
  • 476
  • 4
  • 16
  • 2
    This is unlikely to be possible - this sort of UI behaviour is usually under the control of the user, not the webpage. – James Thorpe Nov 10 '16 at 15:17
  • @Quentin - I think this is not what the OP wants. Sure, opening a link in a new tab is easy, but he wants to **open a new window of Chrome** and **within this new window, the page should be shown in a tab** instead of the no-tabbed interface like in the first image! – linusg Nov 10 '16 at 15:25

2 Answers2

1

Unfortunately, it is not possible. Using window.open() you can either open a new window by providing properties as the third parameter, as you have. This simply opens a basic browser with the URL displayed.

Or you can open a new tab within the current browser by not providing window properties in the third parameter. Consider the following

window.open("http://google.com")

Adds a new tab to the current browser.

From what I can tell, and have tested, it is not possible to do both.

Paul Stoner
  • 1,359
  • 21
  • 44
  • So far this seems like no one was able to open it this way. From curiosity tried 'opening new tab' from within the new window, and it actually opens new tab in the main chrome application and not the window, which is interesting. If flash was still around, it probably would be possible to run new instance of chrome application. – Dmitriy Kravchuk Nov 10 '16 at 16:21
  • @DmitriyKravchuk. You are probably correct. Also, given enough time, we could probably come up with some sort of hack, but I really think it would be more time than its work. As I am sure you are aware, window.open() was(is) the go to for opening a popup window to display additional information to the user. I don't think it was ever meant to be a means to opening a new browser session, just a window. – Paul Stoner Nov 10 '16 at 16:24
-2

I'm not sure you can do what you are trying to do, exactly as you describe it.

The best I think you can get, is opening it like an anchor tag could.

Link

But I don't think this provides the functionality you need

EDIT

http://www.w3schools.com/jsref/met_win_open.asp

This link gives some insight on the window.open

Under the parameter values, you have :

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 (Note: the name does not specify the title of the new window)

Maybe you have tried these, maybe not, but this parameter might be able to do what you need

Zachary Brooks
  • 303
  • 2
  • 9
  • An `a` tag will allow you to specify `_blank`, but it's up to the user whether that opens a new window or a new tab, not the webpage. You can't force it. – James Thorpe Nov 10 '16 at 15:19
  • I didn't know that. But I was really suggesting it, because it WILL open up as a tab instead of a stand-alone window, right? – Zachary Brooks Nov 10 '16 at 15:21
  • The behaviour of `_blank` is entirely down to user settings. If they have it set to open in new tabs, it'll open a new tab. If it's set to open new windows, it'll open a new window. There's nothing you can do as a web page author to force one or the other. – James Thorpe Nov 10 '16 at 15:22
  • I'm aware of behaviors offered and what they do more or less. I've tried just about any combination of properties. Chrome has many features, as well as that option is available with CTRL+N which puts it on the line of yes and no. I want to achieve **new window with a tab inside** if possible. – Dmitriy Kravchuk Nov 10 '16 at 15:32
  • @Quentin The material I quoted however does provide a range of things that he can do. The question was given the answer before I was here in the comments, so I am trying to help him how I can, even if it might not be what he wants. Provide an answer for him yourself otherwise. – Zachary Brooks Nov 10 '16 at 15:39
  • 1
    "The material I quoted however does provide a range of things that he can do." — Answers are supposed to actually answer the question. Not quote some documentation which gives a *range* of things which are a combination of entirely irrelevant and *possibly* useful stuff. – Quentin Nov 10 '16 at 15:58