6

I have this JS function who activates when a button is clicked:

function redirect() {
        win = window.open(\"$ref\", target=\"_blank\");
        win2 = window.open(\"$ref\", target=\"_blank\");
        win3 = window.open(\"$ref\", target=\"_self\");
}

First call to window.open opens a new tab in Chrome, second window.open opens a new window and the third window.open successfully "redirects" the original window to $ref.

My question is: why the first and the second window.open open both a tab and a window? Is there any way to open only tabs?

Shadark
  • 499
  • 1
  • 7
  • 18
  • Looks like it's explained in http://stackoverflow.com/questions/16749907/window-open-behaviour-in-chrome-tabs-windows?rq=1 – Shadark Nov 20 '13 at 11:20
  • possible duplicate of [Open url in new tab using javascript](http://stackoverflow.com/questions/4907843/open-url-in-new-tab-using-javascript) – Vicky Gonsalves Nov 20 '13 at 11:22

1 Answers1

4

A have solved this problem and create a gist. It open 3 links in tabs.

Alex
  • 11,115
  • 12
  • 51
  • 64
  • 1
    THANK YOU VERY MUCH!!! After looking for months, almost hundreds of posts here in StackOverflow, asking my teachers & friends about this, at last someone posted a valid solution. You have my eternal gratitude. I was thinking something like that: creating some hidden structure holding the URLs I wanted to open in tabs and then emulating clicks in them to open in new tabs. But you managed to write it when I couldn't, so have my thanks ;) – Shadark Nov 21 '13 at 10:28
  • One last question. I'm testing the code on IE but the line element.fireEvent('onclick', evt) gives me an error in IE (SCRIPT16389: Unspecified error). Any idea why this is happening? – Shadark Nov 22 '13 at 08:10
  • IE version? I will check the gist. – Alex Nov 22 '13 at 10:35
  • I managed to solve it checking if the navigator was IE and then entering in the same part of the loop as FF. – Shadark Dec 07 '13 at 19:47