首页 > 解决方案 > 在 IE11 中下载 pdf 时弹出

问题描述

我收到一个弹出窗口“您要允许此网站在您的计算机上打开应用程序吗?” 在 IE11 中下载 pdf 时。

使用下面的代码,打开正确的弹出窗口“您要打开还是保存文件”?还有“你想让这个网站在你的电脑上打开一个应用程序吗?”

const headerOptions = new HttpHeaders({
  // 'Cache-Control': 'private',
  // 'Content-Disposition': 'attachment; filename = ' + filename,
  'Content-Type': 'application/pdf'
});

const requestOptions = {
  headers: headerOptions,
  responseType: 'blob' as 'blob'
};

this.http
  .post(
    `${this.url}?id=${id}&datasource=${datasource}&device=${device}&browser=${browser}&link=${link}`,
    dataObj,
    requestOptions
  )
  .catch(error => { 
    return this.clickHandlerError(error);
  })
  .pipe(
    map((data: any) => {
      const blob = new Blob([data], {
        type: 'application/pdf'
      });

      window.navigator.msSaveOrOpenBlob(blob, filename);
    })
  )
  .subscribe((result: any) => {});

我希望只有正确的弹出窗口来打开或保存文件。

标签: angularjsinternet-explorer-11

解决方案


这是一条客户端错误消息,让用户知道此操作将导致应用程序在用户系统上打开。如果您希望停止此操作,则需要配置客户端计算机而不是 Web 应用程序。

我建议您检查您的 IE 选项并禁用此提示。

如果问题仍然存在,您可以重置您的 IE 应用程序可以帮助解决此问题。


推荐阅读