Loading WebViewer in jQuery UI tabs in Firefox

87 views
Skip to first unread message

Matt Parizeau

unread,
Dec 11, 2014, 1:30:22 PM12/11/14
to pdfnet-w...@googlegroups.com
Q:

When i use the web viewer in jquery UI tab pages (not the first page), there is an error "getComputedStyle(...) is null" when creating the web viewer (html5 mode), drop.js line 29.
This error is shown in Firefox only, checked that this may be the bug of firefox:
Bug 548397 - window.getComputedStyle() returns null inside an iframe with display: none

A:

It's unfortunate that this Firefox bug exists but you can probably work around it by not initializing WebViewer until the tab is activated.
For example you could add a class to the tab with WebViewer in it and then check that in the tabsactivate event.

var init = false;
$
('#tabs').on('tabsactivate', function(e, ui) {

   
if (!init && ui.newTab.hasClass('webviewerTab')) {
        init
= true;
       
var viewerElement = document.getElementById('viewer');
        myWebViewer
= new PDFTron.WebViewer({
             
....
             
....
       
}, viewerElement);
   
}
});

Reply all
Reply to author
Forward
0 new messages