[CRX] Delay render of viewer if needed...
Sometimes, the viewer did not render for PDF files in an iframe, because document.readyState not reaching "complete". Deferring window.stop() until the root element is placed in the document fixes the problem (typically a few ten milliseconds).
This commit is contained in:
parent
ec5ef58b84
commit
ec956d97c9
@ -27,6 +27,12 @@ function getViewerURL(pdf_url) {
|
||||
}
|
||||
|
||||
function showViewer(url) {
|
||||
if (document.documentElement === null) {
|
||||
// If the root element hasn't been rendered yet, delay the next operation.
|
||||
// Otherwise, document.readyState will get stuck in "interactive".
|
||||
setTimeout(showViewer, 0, url);
|
||||
return;
|
||||
}
|
||||
// Cancel page load and empty document.
|
||||
window.stop();
|
||||
document.body.textContent = '';
|
||||
|
Loading…
x
Reference in New Issue
Block a user