From 035667b0e15c81de09b0ed086d7d48a69667adfd Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Wed, 3 May 2023 16:56:55 +0400 Subject: [PATCH] fixup! Fixed external links in the viewer iframe --- static/skin/viewer.js | 6 ++++-- static/viewer.html | 1 + test/server.cpp | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/static/skin/viewer.js b/static/skin/viewer.js index 2c3c80a14..09bed7ad8 100644 --- a/static/skin/viewer.js +++ b/static/skin/viewer.js @@ -257,7 +257,7 @@ function isExternalUrl(url) { || url.startsWith("https:"); } -function onClickEvent(e) { +function handleLinkClick(e) { const iframeDocument = contentIframe.contentDocument; const target = matchingAncestorElement(e.target, iframeDocument, "a"); if (target !== null && "href" in target) { @@ -266,6 +266,8 @@ function onClickEvent(e) { if ( viewerSettings.linkBlockingEnabled ) { return blockLink(target); } + } else { + target.setAttribute("target", "content_iframe"); } } } @@ -301,7 +303,7 @@ this.Element && function(ElementPrototype) { }(Element.prototype); function setup_external_link_blocker() { - setupEventHandler(contentIframe.contentDocument, 'a', 'click', onClickEvent); + setupEventHandler(contentIframe.contentDocument, 'a', 'click', handleLinkClick); } //////////////////////////////////////////////////////////////////////////////// diff --git a/static/viewer.html b/static/viewer.html index fc49f6ac7..18dba637c 100644 --- a/static/viewer.html +++ b/static/viewer.html @@ -69,6 +69,7 @@