Dmitriy Kravchuk Dmitriy Kravchuk - 26 days ago 8
HTML Question

JavaScript - open new window and display as a tab (chrome CTRL+N equivalent)

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

Answer

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.