diff --git a/searx/webapp.py b/searx/webapp.py index 68e95fafd..7fd248f97 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -1304,9 +1304,13 @@ function modal_open(url, num) resolve("success"); }); } else if (num=='pdf') { - iframe.contentDocument.addEventListener('pagesloaded', function (e) { + iframe.contentDocument.addEventListener("webviewerloaded", function() { + PDFViewerApplication.initializedPromise.then(function() { + PDFViewerApplication.eventBus.on("documentloaded", function(event) { resolve("success"); - }, true); + }); + }); + }); }else{ iframe.onload = function() { resolve("success"); diff --git a/searx/webapp1.py b/searx/webapp1.py index 68e95fafd..7fd248f97 100644 --- a/searx/webapp1.py +++ b/searx/webapp1.py @@ -1304,9 +1304,13 @@ function modal_open(url, num) resolve("success"); }); } else if (num=='pdf') { - iframe.contentDocument.addEventListener('pagesloaded', function (e) { + iframe.contentDocument.addEventListener("webviewerloaded", function() { + PDFViewerApplication.initializedPromise.then(function() { + PDFViewerApplication.eventBus.on("documentloaded", function(event) { resolve("success"); - }, true); + }); + }); + }); }else{ iframe.onload = function() { resolve("success");