Opening a new page: new window and new tab

I have my web browser (Firefox 10 and Chrome 16), so when a new page opens, it opens in the same window on a new tab. When I write a local file as follows:

<html><body><input type="button" onclick="window.open();"/></body></html> 

and access this location from a web browser and click the button, a new page will open in the same window on a new tab . It is expected.

However, when I use the local web server (Ruby + Webrick) and dynamically generate the same as above, and access this localhost:3000 location, and click the button, a new page will open in a new window . Why does it behave differently from above and how can I fix the code so that it opens in the same window on a new tab ?

If I do instead

 <html><body><input type="button" onclick="window.open("", "_self");"/></body></html> 

then a new page opens on the same tab, that is, overwrites the current page .

+4
source share
1 answer

In general, if you provide dimensions using window.open , you get a new window. If you do not, you will receive a new tab.

I would suggest that specifying _self does the same.

+2
source

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


All Articles