title: Open a new tab in Safari programmatically using JS
body: <p>I am developing on an Ember.js platform with an Microsoft Azure database for uploaded files. Since the content of these files are sensitive, we're relying on Azure's secure access api to allow our users to view the file for about 2 minutes, then expiring the access link. This secure access link is returned to my application as <code>response.fileURL</code>. </p>
  
  <p>The problem is that I need to open this link in a new tab, and the methods I've tried work on every browser so far except for Safari. </p>
  
  <p>Now, after searching for "open new tab on safari programmatically" for a while, every result I've found online so far (for example, <a href="http://whoknew.dk/programmatically-opening-a-new-tab-window-on-mobile-safari-55.htm" rel="noreferrer">http://whoknew.dk/programmatically-opening-a-new-tab-window-on-mobile-safari-55.htm</a>) has an implementation that has some interpretation of the following code:</p>
  
  <pre><code>function openURL(){
      var a = window.document.createElement("a");
      a.target = '_blank';
      a.href = response.fileURL;
  
      // Dispatch fake click
      var e = window.document.createEvent("MouseEvents");
      // e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
      e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, true, false, false, false, 0, null); 
      a.dispatchEvent(e);
  }
  
  openURL();
  </code></pre>
  
  <p>Since a simple </p>
  
  <pre><code>&lt;a target="_blank" href='link.com'&gt;link&lt;/a&gt;
  </code></pre>
  
  <p>won't work and I am required to open this tab programmatically anyway, I have tried the above function to no avail. This issue is keeping our application from being able to open files on apple smartphones and tablets. And to make matters worse, Safari doesn't even notify the user that the 'popup' was blocked, so our users simple think this feature is broken when in fact it works in other browsers. </p>
  
  <p>How do I open any link/file in a new tab in safari?</p>