woytech
woytech

Reputation: 771

How to open multiple e-mail client windows by window.open in Chrome?

I have the following html/js code:

<button onclick="openWindows()">Open 3 e-mail windows</button>
<script>
      function openWindows(){
          window.open("mailto:[email protected]","_self",'PopUp1');
          window.open("mailto:[email protected]","_self",'PopUp2');
          window.open("mailto:[email protected]","_self",'PopUp3');
      } 
</script>

This code should open 3 different e-mail client windows. In the IE and FF the code works correctly, but in Chrome only one (the last) window is displayed. Is there any browser independent solution which allows to open multiple windows all at once?

Upvotes: 2

Views: 1920

Answers (2)

Kyle Shay
Kyle Shay

Reputation: 688

I just ran into the same issue. Changing it to _blank did not work for me (on chrome 43).

Instead I added a setTimeout to the mailto calls and it worked as expected.

Around 500ms between messages seems to work for me.

      setTimeout(function() {window.open("mailto:[email protected]","_self",'PopUp1');}, 500);
      setTimeout(function() {window.open("mailto:[email protected]","_self",'PopUp2');}, 1000);
      setTimeout(function() {window.open("mailto:[email protected]","_self",'PopUp3');}, 1500);

Upvotes: 0

Shay Elkayam
Shay Elkayam

Reputation: 4158

Change the "_self" with "_blank".

Beware - many browsers block popups by default.

Upvotes: 1

Related Questions