سؤال

I call two window.open, but only the first one seems to be working. What is going on there?

<button id="open-two">Open two windows</button>

var openTwo = document.getElementById("open-two");
openTwo.addEventListener("click", function() {
    window.open("http://bing.com");
    window.open("http://google.com");
});

A fiddle here

I am using Chrome when testing this.

هل كانت مفيدة؟

المحلول

It's the built-in popup blocker. Chrome (correctly) thinks you're opening a lot of windows, so it tries to stop you. You can confirm this by looking for a little icon with a red X on the right side of the address bar in the original window.

You will either need users to disable the popup blocker or find a different way to do this.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top