title: JavaScript click() method only works once in Chrome extension
body: <p>I'm trying to download multiple files in a Chrome extension. The following code creates a dummy link to a file, then triggers the .click() event which downloads the file.
  The problem is that only the first .click() event triggers a download. Subsequent .click() events are ignored.</p>
  
  <p>Here the <strong>manifest.json</strong>:</p>
  
  <pre><code>{
    "name": "Simple File Downloader",
    "version": "0.1",
    "permissions": ["contextMenus", "http://*/"],
    "background": {
      "persistent": false,
      "scripts": ["sample.js"]
    },
    "content_security_policy": "script-src 'self'; object-src 'self'",
    "manifest_version": 2
  }
  </code></pre>
  
  <p>Here the <strong>sample.js</strong>:</p>
  
  <pre><code>function onClickHandler(info, tab) {
      var a = document.createElement('a');
      a.href = 'http://or.cdn.sstatic.net/chat/so.mp3';
      a.download = 'so.mp3';
      document.body.appendChild(a);
      a.click(); // this click triggers the download
      // this timeout violates content security policy
      // setTimeout(a, 300); 
      a.click(); // this click doesn't do anything
      document.body.removeChild(a);
  
      a = document.createElement('a');
      a.href = 'http://or.cdn.sstatic.net/chat/so.mp3';
      a.download = 'so.mp3'; 
      document.body.appendChild(a);
      a.click(); // this click doesn't do anything either
      document.body.removeChild(a);
  };
  
  chrome.contextMenus.onClicked.addListener(onClickHandler);
  chrome.runtime.onInstalled.addListener(function() {
    chrome.contextMenus.create({"title": "Download File", "id":"download_file"});
  });
  </code></pre>
  
  <p>I've tried:</p>
  
  <ul>
  <li><p>different approaches for downloading files as described in <a href="https://stackoverflow.com/questions/8058493/chrome-extension-write-to-file-system">Chrome Extension write to file system</a> using FileSaver.js, with the exact same result, first file is downloaded, second one is not</p></li>
  <li><p>adding timeouts as described in <a href="https://stackoverflow.com/questions/851384/is-it-possible-to-make-two-click-method-calls-in-javascript">Is it possible to make two .click method calls in javascript</a>, resulting in content-security-policy violation, which I tried to work around using the approach described in <a href="https://stackoverflow.com/questions/11045653/content-security-policy-error-in-google-chrome-extension-making">Content-Security-Policy error in google chrome extension making</a>, but without success</p></li>
  <li><p>using the jQuery .live method as described in <a href="https://stackoverflow.com/questions/10194728/jquery-click-event-works-only-once">JQuery click event works only once</a>, also without success, but I'm not 100% sure I implemented this one correctly (can post code later if people think this approach should solve it)</p></li>
  </ul>
  
  <p>Surprised why it's so hard to simply save multiple files. Appreciate any help. </p>