Downloading PDF as Blob with JS in IE9

你离开我真会死。 提交于 2019-12-23 12:57:56

问题


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();
                    }

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.


回答1:


As you can read here the Blob constructor is supported from IE version 10. You may want to use PDF.js.



来源:https://stackoverflow.com/questions/28196065/downloading-pdf-as-blob-with-js-in-ie9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!