Why does this JavaScript cause a page to open in a tab for Chrome

Why were these parameters passed to window.open ('SomeWinName') on the tab:

toolbar=1, location=1, directories=1, addressbar=1, scrollbars=1, status=1, menubar=1, resizable=1, outerWidth="+x+", outerHeight="+ 

But if I use these options, the window opens in a new window:

 resizable=1, outerWidth="+x+", outerHeight="+y 
+4
source share
3 answers

This is because when you just use window.open ("name"), it has no parameters for setting the address bar and menu bars and all that. Thus, it opens in a new window without these things. He could not do this on a new tab, since, obviously, this would require the same user interface settings as the current window.

Basically, the โ€œdesiredโ€ behavior from google will open in a new tab. But if he does not have enough information for this, he does the next best and opens a new window.

+1
source

Specifying width or outerWidth forces the new window to a size different from the size of the original window. If the default value of width (the same as the current window), the browser will use the new tab by default (if the user has a new tab and not a new window set in the settings, which, in my opinion, the default is most modern browsers).

0
source

There are no external Width and outerHeight in w3c specs: W3C Specs

So this is good for me:

 var x = y = 10; window.open ('Yeah', "toolbar=1,location=1,directories=1,addressbar=1,scrollbars=1,status=1,menubar=1,resizable=1,width="+x+",height="+y); window.open ('Yeah2', "resizable=1,width="+x+",height="+y); 

It opens two new windows on two different tabs.

0
source

Source: https://habr.com/ru/post/1412384/


All Articles