title: Javascript - downloading a file using Iframe and then removing it
body: <p>What I want to do is:</p>
  
  <ol>
  <li>Append a new iframe to the body and download a file using it.</li>
  <li>Remove the iframe once the file is downloaded..</li>
  </ol>
  
  <p>I read a few posts and came up with this code:</p>
  
  <pre><code>let fileHref = baseLocation + '/excelexports/' + fileName;
  var iframe = document.createElement('iframe');
  iframe.style.display = "none";
  iframe.src = fileHref;
  iframe.onload = function() {
      this.parentNode.removeChild(this);    
  };
  document.body.appendChild(iframe);
  </code></pre>
  
  <p>The problem is the <code>onload</code> callback is not firing after the file is downloaded...</p>