angularjs - PDF文件下载在Ipad移动浏览器(chrome和safari)中不起作用 - Angular JS
问题描述
我有一个 Angular JS 应用程序。我正在尝试使用以下代码在移动浏览器上的新选项卡(来自后端)中下载 PDF 文件。
this.windowHolder.windowObjectReference = window.open("about:blank", "_blank");
this.windowHolder.windowObjectReference.location.href = downloadContentUrl;
在哪里,
windowHolder 是 WindowHolder 类的一个实例,如下所示。
class WindowHolder {
public intervalTimeID: number;
public intervalCallPopup: number;
public windowObjectReference: any;
constructor() {
this.intervalTimeID = 0;
this.intervalCallPopup = 0;
this.windowObjectReference = null;
}
public close() {
if (this.windowObjectReference !== null) {
this.windowObjectReference.close();
this.windowObjectReference = null;
}
}
}
它在除IPAD之外的所有设备和浏览器中都能正常工作。相同的逻辑在 iphone 移动浏览器(safari 和 chrome)中运行良好。问题仅与 IPAD 浏览器有关。
IPAD chrome 中的问题: PDF 文件已下载,但当我尝试打开时显示文件已损坏或损坏。
IPAD Safari 中的问题:根本无法下载 PDF 文件。而是浏览器显示 WebKitBlobResource 错误
我需要修复此代码,以便即使在 IPAD 浏览器中也能下载 PDF。感谢你的帮助。提前致谢。
解决方案
推荐阅读
- python - 测试正态性的不同方法导致相同数据的不同输出
- postgresql - 如何从postgres jsonb嵌套数组中获取字段
- database - 确保 MongoDB 数据库目录具有正确的读/写权限
- .net-core - HtmlRendererCore.PdfSharpCore 版本 1.0.1“找不到合适的字体。”
- javascript - 如何在开发服务器中为 react-scripts 启动调用定义基本 URL
- html - nboots中两个div元素之间不必要的空格
- ios - 在旧 macOS 中运行旧 xcode 项目时遇到问题
- node.js - 如何从终端在 Linux 中手动安装 nodejs
- java - 是否可以检查方法是否在一组类中声明?
- node.js - 如何在 Firebase Cloud Firestore 中添加多行