[From] https://segmentfault.com/q/1010000009470664
查了资料,可以使用微软独家的msSaveBlob, 这个方法支持ie10及以上。
var downloadFileName = self.formatTimestamp()+ ‘-‘ + self.logFilename; if(window.navigator.msSaveBlob){ // for ie 10 and later try{ var blobObject = new Blob([self.output]); window.navigator.msSaveBlob(blobObject, downloadFileName); } catch(e){ console.log(e); } } else{ var file = "data:text/plain;charset=utf-8,"; var logFile = self.output; var encoded = encodeURIComponent(logFile); file += encoded; var a = document.createElement(‘a‘); a.href = file; a.target = ‘_blank‘; a.download = downloadFileName; document.body.appendChild(a); a.click(); a.remove(); }