Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript open in a new window, not tab

I have a select box that calls window.open(url) when an item is selected. Firefox will open the page in a new tab by default. However, I would like the page to open in a new window, not a new tab.

How can I accomplish this?

like image 505
adam Avatar asked Apr 07 '09 17:04

adam


People also ask

How do I open a new window instead of a tab?

Hold down your ⇧ Shift (Mac) or ⇧ Shift (Windows) button. If you want to open the link in a new background tab, hold ⌘ Cmd (Mac) or Ctrl (Windows) instead. If you want to open the link in a new foreground tab, hold both ⌘ Cmd + ⇧ Shift or Ctrl + ⇧ Shift (Windows) instead.

How do I open a script in a new window?

The window. open() method is used to open a new browser window or a new tab depending on the browser setting and the parameter values. Approach: To open a new tab, we have to use _blank in the second parameter of the window.

How do I make a link open in a new window?

Open in a new window To open a link in a new browser window, hold the Shift on then click the link or right-click the link and select Open link in New Window.


1 Answers

Specify window "features" to the open call:

window.open(url, windowName, "height=200,width=200"); 

When you specify a width/height, it will open it in a new window instead of a tab.

See https://developer.mozilla.org/en-US/docs/Web/API/Window.open#Position_and_size_features for all the possible features.

like image 59
DNS Avatar answered Sep 25 '22 17:09

DNS