From abb8c01b2a3024c45fb04a687ae02735ff7157ea Mon Sep 17 00:00:00 2001 From: Joseph Cheung Date: Mon, 6 Mar 2023 10:23:12 +0800 Subject: [PATCH] c --- searx/webapp.py | 17 +++++++++-------- searx/webapp1.py | 17 +++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/searx/webapp.py b/searx/webapp.py index 7fd248f97..b145c595e 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -1299,19 +1299,20 @@ function modal_open(url, num) var iframePromise = new Promise((resolve, reject) => { var iframe = document.querySelector("#iframe-wrapper > iframe"); iframe.src = url; - if (iframe.attachEvent&&num!='pdf') { - iframe.attachEvent("onload", function() { - resolve("success"); - }); - } else if (num=='pdf') { + if (num=='pdf') { iframe.contentDocument.addEventListener("webviewerloaded", function() { - PDFViewerApplication.initializedPromise.then(function() { - PDFViewerApplication.eventBus.on("documentloaded", function(event) { + iframe.contentWindow.PDFViewerApplication.initializedPromise.then(function() { + iframe.contentWindow.PDFViewerApplication.eventBus.on("documentloaded", function(event) { resolve("success"); }); }); }); - }else{ + } + else if (iframe.attachEvent) { + iframe.attachEvent("onload", function() { + resolve("success"); + }); + } else{ iframe.onload = function() { resolve("success"); }; diff --git a/searx/webapp1.py b/searx/webapp1.py index 7fd248f97..b145c595e 100644 --- a/searx/webapp1.py +++ b/searx/webapp1.py @@ -1299,19 +1299,20 @@ function modal_open(url, num) var iframePromise = new Promise((resolve, reject) => { var iframe = document.querySelector("#iframe-wrapper > iframe"); iframe.src = url; - if (iframe.attachEvent&&num!='pdf') { - iframe.attachEvent("onload", function() { - resolve("success"); - }); - } else if (num=='pdf') { + if (num=='pdf') { iframe.contentDocument.addEventListener("webviewerloaded", function() { - PDFViewerApplication.initializedPromise.then(function() { - PDFViewerApplication.eventBus.on("documentloaded", function(event) { + iframe.contentWindow.PDFViewerApplication.initializedPromise.then(function() { + iframe.contentWindow.PDFViewerApplication.eventBus.on("documentloaded", function(event) { resolve("success"); }); }); }); - }else{ + } + else if (iframe.attachEvent) { + iframe.attachEvent("onload", function() { + resolve("success"); + }); + } else{ iframe.onload = function() { resolve("success"); };