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, i.e., overwrites the current page.