11
我正在尝试使用本文中提出的方法AngularJS: Display blob (.pdf) in an angular app显示一个二进制文件。这在Chrome和FF中很好地工作,但IE 11给我“错误:访问被拒绝”。 有没有人知道它是否与Blob对象有关,并可以指向正确的方向? 这里是我的js代码:在IE中显示二进制文件(pdf)11
$http.get(baseUrl + apiUrl, { responseType: 'arraybuffer' })
.success(function (response) {
var file = new Blob([response], { type: 'application/pdf' });
var fileURL = URL.createObjectURL(file);
$scope.pdfContent = $sce.trustAsResourceUrl(fileURL);
})
.error(function() {
});
和我的html:
<div ng-controller="PDFController" class="modal fade" id="pdfModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content" onloadstart="">
<object data="{{pdfContent}}" type="application/pdf" style="width:100%; height:1000px" />
</div>
</div>
解决方法:我终于使用了[FileSaver.js](https://github.com/eligrey/FileSaver.js/),但如果任何人都可以告诉我,我仍然会很感激为什么上述技术在IE 11中不起作用... – jymuk 2014-10-06 07:24:04
我也遇到过这个问题,你是否曾经在没有FileSaver.js的情况下工作? – Madhatter5501 2014-10-29 20:43:31
不,我没有遗憾... – jymuk 2014-11-03 09:25:12