Browse Source

[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).
Rob Wu 12 years ago
parent
commit
ec956d97c9
  1. 6
      extensions/chrome/insertviewer.js

6
extensions/chrome/insertviewer.js

@ -27,6 +27,12 @@ function getViewerURL(pdf_url) { @@ -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…
Cancel
Save