rndme / download

file downloading using client-side javascript
MIT License
2.28k stars 417 forks source link

A solution for ie9 #87

Closed ghwyf closed 5 years ago

ghwyf commented 5 years ago

https://www.joshmcarthur.com/til/2019/02/13/javascript-based-file-downloads-in-ie9.html


    // IE 9
    if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/9./i) == "9.") {
      var frame = document.createElement("iframe");
      frame.style.display = "none";
      document.body.appendChild(frame);

      frame.contentWindow.document.open("text/html", "replace");
      frame.contentWindow.document.write(blob);
      frame.contentWindow.document.close();

      frame.contentWindow.focus();
      frame.contentWindow.document.execCommand("SaveAs", true, fileName);
      document.body.removeChild(frame);
      return
    }