title: Open multiple tabs with jQuery
body: <p>Ok, I feel I have done my due diligence here... JSFIddle - <a href="http://jsfiddle.net/taytayevanson/8BpHw/5/" rel="nofollow noreferrer">http://jsfiddle.net/taytayevanson/8BpHw/5/</a></p>
  
  <p>I am trying to create a page that will pop multiple tabs. I understand that using this code...</p>
  
  <pre><code>&lt;a href="google.com" target="_blank"&gt;New Tab&lt;/a&gt;
  </code></pre>
  
  <p>will pop <strong>1</strong> new tab. However, as explained in <a href="https://stackoverflow.com/questions/15818892/chrome-javascript-window-open-in-new-tab">this</a> stackoverflow q/a, it needs to be a "user initiated event" for Chrome to pop a new tab and not a window. Because of this requirement, a loop will pop 1 new tab and then new windows for each following link.</p>
  
  <pre><code>jQuery("a.site").each(function(){
      var string = jQuery(this).attr("href") + "/" + jQuery("#arguments").val();
      jQuery(this).attr("href",string);
      jQuery(this).trigger('click');
  });
  </code></pre>
  
  <p>I have tried programmatically creating links and clicking them, with different plugins, timeouts, methods, and I even tried "daisy-chaining" the process and firing it on a page load (a huge PHP/GET variable/page load trigger thing) but it would still pop windows because the event was not user initiated.</p>
  
  <p>I tried <a href="https://stackoverflow.com/questions/8996193/how-do-i-open-a-new-tab-window-using-javascript">this</a>...</p>
  
  <pre><code>function clickLink(link) {
  var cancelled = false;
  
  if (document.createEvent) {
      var event = document.createEvent("MouseEvents");
      event.initMouseEvent("click", true, true, window,
          0, 0, 0, 0, 0,
          false, false, false, false,
          0, null);
      cancelled = !link.dispatchEvent(event);
  }
  else if (link.fireEvent) {
      cancelled = !link.fireEvent("onclick");
  }
  
  if (!cancelled) {
      window.location = link.href;
  }
  }
  </code></pre>
  
  <p>and although I can read it, I don't understand it well enough to comprehend what i'm supposed to pass into this function. I tried something like this...</p>
  
  <pre><code>jQuery("a.site").each(function(){
      var string = jQuery(this).attr("href") + "/" + jQuery("#launcher").val();
      jQuery(this).attr("href",string);
      clickLink(jQuery(this));
  });
  </code></pre>
  
  <p>But I get a "object has no method 'dispatchEvent'" console error. I tried using that same "var event" and just calling...</p>
  
  <pre><code>link.trigger(event);
  </code></pre>
  
  <p>but there was a console error there as well. The only thing I have not tried is in <a href="https://stackoverflow.com/questions/11999837/force-window-open-to-create-new-tab-in-chrome">this</a> Q/A (using jQuery.get() to open a tab and write to it) but seeing as it still calls window.open(), I feel like i'll still run into the exact same loop issue.</p>
  
  <hr>
  
  <p>Ok. Got all that out of the way... Is there a real answer for this besides "it's controlled by your browser" ? I feel like there must be a way. Thank you, sorry for the novel <strong>:)</strong></p>