How to open mulitple tabs at once [JavaScript]

I have a button that is purposely designed to open multiple pages at once, it is the main feature of the button.

I tried using:

(1)

urls.forEach(url => {
  window.open(url);
});

(2) promises with a delay on them but that did not work either.

(3) multiple a tags and trying to simulate a human click however, that did not work either.

var element = document.createElement("a");
element.href = tempUrl;
element.innerHTML = "temp";
element.id = "tempAtag";
element.target = "_blank";
document.getElementById("dashboardID").appendChild(element);
element = document.getElementById("tempAtag");
var box = element.getBoundingClientRect(),
coordX = box.left + (box.right - box.left) / 2,
coordY = box.top + (box.bottom - box.top) / 2;
var simulateMouseEvent = function (element, eventName, coordX, coordY) {
  element.dispatchEvent(
    new MouseEvent(eventName, {
      view: window,
      bubbles: true,
      cancelable: true,
      clientX: coordX,
      clientY: coordY,
      //button: 0,
    })
  );
};
simulateMouseEvent(element, "mousedown", coordX, coordY);
simulateMouseEvent(element, "mouseup", coordX, coordY);
simulateMouseEvent(element, "click", coordX, coordY);

This does work for the first link but I get a warning in the console saying I am trying to open multiple tabs with only one interaction. So it works for one link but not for the rest.

I got the code from Simulate a REAL HUMAN mouse click in pure javascript?

(Note: I did delete my a tags after each iteration and I did test it out, there are no duplicates)

I ran out of ideas. Any ideas?

(I have looked at other solutions and none of what I came across has worked for me)

154 thoughts on “How to open mulitple tabs at once [JavaScript]”

  1. hello!,I love your writing very so much! share we
    keep up a correspondence extra approximately your post on AOL?
    I need an expert on this area to unravel my problem.
    May be that is you! Having a look ahead to peer you.

    Reply
  2. You can certainly see your skills within the article you write.
    The arena hopes for more passionate writers like you
    who aren’t afraid to mention how they believe. At all times go
    after your heart.

    Reply
  3. Wow, superb weblog format! How lengthy have you been blogging for? you made running a blog look easy. The entire glance of your website is fantastic, let alone the content material!

    Reply
  4. With havin so much content and articles do you ever
    run into any issues of plagorism or copyright infringement?
    My site has a lot of completely unique content I’ve either created myself or
    outsourced but it looks like a lot of it is popping it up all over
    the web without my authorization. Do you know any ways to help stop content from being ripped off?
    I’d certainly appreciate it.

    Reply
  5. you’re really a excellent webmaster. The website loading pace
    is amazing. It sort of feels that you’re doing any unique trick.
    In addition, The contents are masterpiece. you have done a fantastic task on this subject!

    Reply
  6. I really love your blog.. Excellent colors & theme. Did you make this website yourself?

    Please reply back as I’m trying to create my very own blog and would love to find
    out where you got this from or exactly what the theme is named.
    Thanks!

    Reply
  7. Pingback: sildenafil viagra
  8. Pingback: herbal viagra
  9. Pingback: cialis website
  10. Pingback: viagra samples
  11. Pingback: sildenafil 50 mg
  12. Pingback: cheap viagra 25mg
  13. Pingback: herbal cialis
  14. Pingback: viagra/canada
  15. Pingback: cialis on line
  16. Pingback: cialis prices
  17. Pingback: cialis pill
  18. Pingback: sildenafil online
  19. Pingback: otc viagra
  20. What i don’t understood is in reality how you’re not really
    much more smartly-appreciated than you might be right now.
    You’re so intelligent. You recognize thus significantly
    when it comes to this topic, made me individually
    believe it from a lot of numerous angles. Its like men and
    women are not involved except it’s something to do with
    Woman gaga! Your personal stuffs excellent. At all
    times deal with it up!

    Reply
  21. Pingback: natural viagra
  22. Pingback: womens viagra
  23. Pingback: goodrx viagra
  24. Pingback: sildenafilo
  25. Pingback: viagra users group
  26. Pingback: viagra dosage
  27. Pingback: viagra walmart
  28. Pingback: viagra pill
  29. Pingback: roman viagra
  30. Pingback: cialis tablets

Leave a Comment