简体   繁体   中英

Opening a new page: New window vs. New tab

I have my web browser (Firefox 10 and Chrome 16) set so that when a new page opens, it is opened within the same window in a new tab. When I write a local file like this:

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

and access that location from a web browser and click the button, the new page opens within the same window in a new tab . That is expected.

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

If I instead do

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

then the new page opens in the same tab, ie, overwrites the current page .

In general if you provide dimensions with window.open you get a new window. If you don't you get a new tab.

I would imagine specifying _self does the same.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM