【问题标题】:pdf.js error in IE11, src property (0x800a138f)IE11 中的 pdf.js 错误,src 属性 (0x800a138f)
【发布时间】:2016-06-03 20:43:05
【问题描述】:


我的应用程序使用 pdf.js 显示 pdf。一切正常,但当然 IE 不行。启动时抛出异常:

Unhandled exception at line 8290, column 5 in http://.../scripts/pdf-js/pdf.js

0x800a138f - Timeout execution error JavaScript Code: Couldn't load(get) "src" property fo undefined or empty call.

渲染 pdf 一切正常,我只想摆脱这个异常。 (请注意,我正在翻译“0x800a138f”之后的错误消息。如果有人知道确切的英文错误内容,我会更改它和问题标题)。

更新
每次应用程序启动都会发生错误。正如我所说,一切正常。 pdf.js 脚本中出现异常的行:

if (!PDFJS.workerSrc && typeof document !== 'undefined') {
  // workerSrc is not set -- using last script url to define default location
 PDFJS.workerSrc = (function () {
    'use strict';
     var pdfJsSrc = document.currentScript.src; // here the src cannot be found
     return pdfJsSrc && pdfJsSrc.replace(/\.js$/i, '.worker.js');
   })();
}

【问题讨论】:

  • mozilla.github.io/pdf.js/web/viewer.html 没有此类错误。请提供更多信息和步骤来重现该问题。因为这个问题无法解决。
  • 我用 IE 发现异常的确切代码更新了问题。我不确定重现的步骤,因为它发生在应用程序启动时。
  • 你指的是哪个应用程序?
  • 它是一个 .NET MVC 应用程序,使用 Typescript 编写的 Angular 管理 UI 行为。 Chrome 或 Firefox 没有这样的问题。

标签: javascript angularjs asp.net-mvc internet-explorer pdf.js


【解决方案1】:

尽管我不知道安全性如何,但我对这个问题的解决方案非常简单。在我的特定情况下,在我添加另一个条件后,pdf 查看效果很好:

if (!PDFJS.workerSrc && typeof document !== 'undefined' && typeof document.currentScript !== 'undefined' ) {
  // workerSrc is not set -- using last script url to define default location
  PDFJS.workerSrc = (function () {
  'use strict';
   var pdfJsSrc = document.currentScript.src;
   return pdfJsSrc && pdfJsSrc.replace(/\.js$/i, '.worker.js');
   })();
}

【讨论】:

【解决方案2】:

包含 compatibility.js 以修复 IE11 上的错误。

https://github.com/mozilla/pdf.js/blob/master/web/compatibility.js

<script src="compatibility.js"></script>

compatibility.js 实现了 PDFJS 所需的任何缺失功能。

这还修复了其他错误,例如某些 pdf 无法在 Safari 上加载。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-09
    • 2015-01-27
    • 1970-01-01
    • 1970-01-01
    • 2015-07-07
    • 2014-02-22
    • 1970-01-01
    相关资源
    最近更新 更多