alpaca095
alpaca095

Reputation: 13

Why can't I use window.open() to open multiple pages?

function input_check() {
  var num = $("#num").val();
  var sys = $("#sys").val();
  var tp = $("#tp").val();
  var urlstring1 = "";
  var urlstring2 = "";


  if (sys === 'QA') {
    if (tp === 'ACOs') {
        urlstring1 = "http://stackoverflow.com";
        urlstring2 = "http://google.ca";
        window.open(urlstring2);
        window.open(urlstring1);
    }       
    else {
      console.log(0)
    };
  };
};


$(document).ready(function() {
  $('#checkBtn').on('click', input_check);
});

I want Stackoverflow and Google open, but

Upvotes: 0

Views: 539

Answers (2)

raviolicode
raviolicode

Reputation: 2175

According to MDN Reference Window.open() , you also probably need to add a target:

window.open(urlstring1, "target1"); window.open(urlstring2, "target2");

Upvotes: 0

Adam Heath
Adam Heath

Reputation: 4743

This will be due to your browsers popup blocker, which usually only allows on popup per user action.

Upvotes: 1

Related Questions