mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
[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
1 changed files with 6 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue