diff --git a/static/skin/viewer.js b/static/skin/viewer.js index 59242e591..99ee06c44 100644 --- a/static/skin/viewer.js +++ b/static/skin/viewer.js @@ -345,6 +345,13 @@ function setHrefAvoidingWombatRewriting(target, url) { target._no_rewrite = old_no_rewrite; } +function linkShouldBeOpenedInANewWindow(linkElement, mouseEvent) { + return linkElement.getAttribute("target") == "_blank" + || mouseEvent.ctrlKey + || mouseEvent.shiftKey + || mouseEvent.metaKey /* on Macs */; +} + function onClickEvent(e) { const iframeDocument = contentIframe.contentDocument; const target = matchingAncestorElement(e.target, iframeDocument, "a"); @@ -358,7 +365,7 @@ function onClickEvent(e) { if (isExternalAppUrl || isExternalUrl(target_href)) { const possiblyBlockedLink = blockLink(target_href); - if ( e.ctrlKey || e.shiftKey ) { + if ( linkShouldBeOpenedInANewWindow(target, e) ) { // The link will be loaded in a new tab/window - update the link // and let the browser handle the rest. setHrefAvoidingWombatRewriting(target, possiblyBlockedLink); diff --git a/test/server.cpp b/test/server.cpp index 066f9d463..8f0b1a3db 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -75,7 +75,7 @@ const ResourceCollection resources200Compressible{ { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/taskbar.css" }, { STATIC_CONTENT, "/ROOT%23%3F/skin/taskbar.css?cacheid=80d56607" }, { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/viewer.js" }, - { STATIC_CONTENT, "/ROOT%23%3F/skin/viewer.js?cacheid=8ca16f13" }, + { STATIC_CONTENT, "/ROOT%23%3F/skin/viewer.js?cacheid=fdec37a7" }, { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/fonts/Poppins.ttf" }, { STATIC_CONTENT, "/ROOT%23%3F/skin/fonts/Poppins.ttf?cacheid=af705837" }, { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/fonts/Roboto.ttf" }, @@ -327,7 +327,7 @@ R"EXPECTEDRESULT( - + const blankPageUrl = root + "/skin/blank.html?cacheid=6b1fa032";