【问题标题】:embed blob pdf doesnt work in IE and Edge嵌入 blob pdf 在 IE 和 Edge 中不起作用
【发布时间】:2017-12-10 14:21:31
【问题描述】:

这部分代码在 Chrome 中运行良好,但在 IE 和 Edge 中却不行。

HTML

<object id="pdfObject" ng-hide="$ctrl.item == false" data="{{content}}" type="application/pdf" style="height: 100%;width: 100%;padding-bottom: 40px;">

<embed id="pdfEmbed" ng-src="{{content}}" type="application/pdf" style="height: 100%;width: 100%;"/></object>

JS

 var file = new Blob([this.item], { type: 'application/pdf' });
 var fileURL = URL.createObjectURL(file);
 $scope.content = $sce.trustAsResourceUrl(fileURL)

this.item 有来自 HTTP 调用的响应。

【问题讨论】:

  • “不起作用”.... 尝试关闭 IE 的 ActiveX 过滤。工具>ActiveX 过滤。设置 IE 以在开发工具控制台中记录被阻止的内容和安全消息...工具>Internet 选项>高级选项卡,选中“始终记录开发者控制台消息”。保存更改。 PDF 文档托管在 IE 中的 ActiveX 控件中... chrome 使用内置插件... 从 IE 使用工具>管理插件>显示所有插件以管理您的 PDF 查看器插件。
  • 大声笑我不想要那种解决方案...
  • 此问题还有其他解决方案吗?

标签: internet-explorer pdf blob embed microsoft-edge


【解决方案1】:

在 embed 标签中属性 src 应该填写 blob 文件的 url,将内容更改为 fileURL 变量并且应该是固定的

var file = new Blob([this.item], { type: 'application/pdf' });
$scope.fileURL = URL.createObjectURL(file); //here is the change
$scope.content = $sce.trustAsResourceUrl(fileURL)

<embed id="pdfEmbed" src="{{fileURL}}" type="application/pdf" style="height: 100%;width: 100%;"/>

问题是 $sce.trustAsResourceUrl 正在返回一个与 src 不匹配的对象

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-03
    • 1970-01-01
    • 2018-04-18
    相关资源
    最近更新 更多