1
<a href="#" onclick="return openTwoWindowTab();">Click Here</a>

<script>
function openTwoWindowTab(){
  window.open('www.google.com','_blank');
  window.open('www.yahoo.com','_blank');
}
</script>

Here i am trying to open two window tabs on click a link.

1) It is working fine in Mozilla Firefox 18.0.2

2) But in google chrome only one tab is opening. Version 35.0.1916.114

3) In Opera also only one tab is opening. Version latest one

It is very critical issue for me...any help/suggestion....

user3676578
  • 213
  • 1
  • 5
  • 17
  • Possible duplicate? Have a look here - http://stackoverflow.com/questions/4907843/open-a-url-in-a-new-tab-using-javascript and here - http://stackoverflow.com/questions/15818892/chrome-javascript-window-open-in-new-tab – PulseLab Jul 04 '14 at 07:34

2 Answers2

1

My suggestion is to do this:

function openTwoWindowTab() {
    // create object to serve the urls
    var obj = {
        0: 'http://www.google.com',
        1: 'http://www.yahoo.com'
    };
    setTimeout(function () { // use setTimeout function to wait for other window to open
                             // otherwise one window will be opened in the browser window
        for (var a = 0; a <= Object.keys(obj).length - 1; a++) {
            window.open(obj[a], '_blank');
        }
    }, 1000);
}

Demo

Jai
  • 74,255
  • 12
  • 74
  • 103
  • In chrome both are opening in new window....In Opera one tab is opening and at right bottom one message block is coming "Pop-up block from ..." click here to open....when i will click on message pop-up then new tab is opening...Mozilla---working fine...@jai – user3676578 Jul 04 '14 at 08:07
  • @user3676578 see for security reason and usability perspective browsers don't allow multiple popups in quick succession so you need to allow popups to be opened for this particular site where you want it to be placed. as i have allowed jsfiddle to open popups at my client machine. – Jai Jul 04 '14 at 08:10
  • when you see `"Pop-up block from ..." click here to open....` message from browser then you can select options available there. try clicking the message in the browser and BTW i don't have Opera browser in my machine so i can't test it for now. – Jai Jul 04 '14 at 08:14
0

HTML

   <a href="javascript:DoubleOpen('http://www.google.com', 'http://www.facebook.com');">Click Here</a>

Javascript

<script>
function DoubleOpen(site1, site2) { 
    window.open(site1); 
    window.location = site2; 
} 
</script> 
cyberoot
  • 340
  • 2
  • 18
  • In Opera one tab is opening and at right bottom one message block is coming "Pop-up block from ..." click here to open....when i will click on message pop-up then new tab is opening. In Chrome one tab and one new window is opening.... – user3676578 Jul 04 '14 at 07:41
  • check again @user3676578 – cyberoot Jul 04 '14 at 07:50
  • now in Parent page only first link is coming ... Actually i want to open two new _blank tabs with parent page should exists there only...@cyberoot – user3676578 Jul 04 '14 at 07:54
  • i try to find bro , let' me think – cyberoot Jul 04 '14 at 08:09