在IE9中使用JS下载PDF作为Blob [英] Downloading PDF as Blob with JS in IE9
本文介绍了在IE9中使用JS下载PDF作为Blob的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个blob并想下载它。它适用于Chrome,Firefox,IE10及更高版本。问题是IE9。
I have a blob and want to download it. It works for Chrome, Firefox, IE10 and higher. The problem is IE9.
var isIE = /*@cc_on!@*/false || !!document.documentMode;
var blob = new Blob([data], {type: "application/pdf"});
if (isIE) {
window.navigator.msSaveOrOpenBlob(blob, "Download.pdf");
} else {
var link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = "Download.pdf";
link.id = "TEST";
$('body').append(link);
document.getElementById("TEST").click();
}
问题出在哪里? IE在URL中具有2.083作为字符的最大限制。也许这很关键。我有什么替代品?我必须支持IE9 ...谢谢。
Where is the problem? The IE has 2.083 as maximal limit for chars in URL. Maybe this is critical. What alternatives do I have? I have to support IE9... Thanks.
推荐答案
您可以阅读这里从IE版本10支持Blob构造函数。您可能想要使用 PDF.js 。
As you can read here the Blob constructor is supported from IE version 10. You may want to use PDF.js.
这篇关于在IE9中使用JS下载PDF作为Blob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文