Javascript viewer.js在IE 11中的tab开关处触发addEventListener resize,导致错误和崩溃
在chrome中,我实现了以下场景: 我有一个网页,里面有多个标签,其中一个包括使用pdfjs显示PDF 当我运行chrome时,一切都很好 在IE11中,我有以下问题。 当我查看pdf选项卡并加载另一个选项卡时,在viewer.js中的以下代码行中出现异常Javascript viewer.js在IE 11中的tab开关处触发addEventListener resize,导致错误和崩溃,javascript,internet-explorer,pdfjs,Javascript,Internet Explorer,Pdfjs,在chrome中,我实现了以下场景: 我有一个网页,里面有多个标签,其中一个包括使用pdfjs显示PDF 当我运行chrome时,一切都很好 在IE11中,我有以下问题。 当我查看pdf选项卡并加载另一个选项卡时,在viewer.js中的以下代码行中出现异常 window.addEventListener('resize', function webViewerResize(evt) { if (PDFViewerApplication.initialized) { //here it caus
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'));
});
例外是
http:/…/pdfjs/web/viewer.js第3列第7548行未处理的异常
0x800a138f-JavaScript中的Laufzeitfehler:Die-Eigenschaft“initialized”是未定义或未定义的。发生
所以据我所知,在IE11中加载另一个标签需要“调整大小”,而chrome没有这样做
问题是如何使IE11不触发此EventListener或在tabselect上告诉它没有pdf,也没有必须加载的pdfjs?解决方案是在加载新的tabstrip-content.empty之前通过tabstrip-content.empty输入旧的tabcontent