4

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.

Dancrumb
  • 26,597
  • 10
  • 74
  • 130
sawa
  • 165,429
  • 45
  • 277
  • 381
  • Not clear about how you generate the page. I tried to serve the page from local web server (mongoose) directly and it works as expected to open window in new tab – rogerz Dec 31 '11 at 04:28
  • @rogerz I see. I will update if I notice something. Thanks so far for trying. – sawa Dec 31 '11 at 04:36

1 Answers1

2

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.

Diodeus - James MacFarlane
  • 112,730
  • 33
  • 157
  • 176