In chrome I got the follow scenario working:
I have a webpage with multiple tabs inside it and one of them includes showing pdfs using pdfjs.
When I run chrome everything is fine.
In IE11 I have the following issue. When I looked at the pdf tab and load another tab I get an exception at the following code lines in the viewer.js
window.addEventListener('resize', function webViewerResize(evt) {
if (PDFViewerApplication.initialized) { //here it causes the exception
var currentScaleValue = PDFViewerApplication.pdfViewer.currentScaleValue;
if (currentScaleValue === 'auto' ||
currentScaleValue === 'page-fit' ||
currentScaleValue === 'page-width') {
// Note: the scale is constant for 'page-actual'.
PDFViewerApplication.pdfViewer.currentScaleValue = currentScaleValue;
} else if (!currentScaleValue) {
// Normally this shouldn't happen, but if the scale wasn't initialized
// we set it to the default value in order to prevent any issues.
// (E.g. the document being rendered with the wrong scale on load.)
PDFViewerApplication.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
}
PDFViewerApplication.pdfViewer.update();
}
// Set the 'max-height' CSS property of the secondary toolbar.
SecondaryToolbar.setMaxHeight(document.getElementById('viewerContainer'));
});
The exception is
Unhandled exception at line 7548, column 3 in http:/.../pdfjs/web/viewer.js 0x800a138f - Laufzeitfehler in JavaScript: Die Eigenschaft "initialized" eines undefinierten oder Nullverweises kann nicht abgerufen werden. occurred
So as far as I understand loading another tab in IE11 it calls for 'resize', which chrome doesn't do.
The question is how can I make IE11 not trigger this EventListener or tell it at tabselect that there is no pdf and no pdfjs must be loaded?
The solution was to enter the old tabcontent via tabstrip-content.empty before loading a new one.
User contributions licensed under CC BY-SA 3.0