My app displays pdfs using pdf.js. Everything works fine, but of course IE does not. It throws an exception while starting:
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.
Everything works fine with rendering pdf, I would just like to get rid of this exception. (Please note that I was translating the error message that comes after "0x800a138f". If someone knows exact english error content I'll change it and the questions title).
UPDATE
Error occurs with each application start. As I said, everything works just fine. The lines of the pdf.js script where exception bumps:
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');
})();
}
Include compatibility.js to fix the errors on IE11.
https://github.com/mozilla/pdf.js/blob/master/web/compatibility.js
<script src="compatibility.js"></script>
compatibility.js implements any missing functionality required by PDFJS.
This also fixes other bugs such as some pdfs not loading on Safari.
My solution to this issue was quite simple although I don't know how safe.In my specific case pdf viewing works well after I added another condition:
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');
})();
}
User contributions licensed under CC BY-SA 3.0