🐛 Fix external jump

This commit is contained in:
Tw93
2024-07-27 22:14:12 +08:00
parent 1544b15ea6
commit 64242e2b72
2 changed files with 5 additions and 2 deletions

Binary file not shown.

View File

@@ -206,13 +206,16 @@ document.addEventListener('DOMContentLoaded', () => {
const detectAnchorElementClick = e => {
const anchorElement = e.target.closest('a');
if (anchorElement && anchorElement.href) {
anchorElement.target = '_self';
if (!anchorElement.target) {
anchorElement.target = '_self';
}
const hrefUrl = new URL(anchorElement.href);
const absoluteUrl = hrefUrl.href;
let filename = anchorElement.download || getFilenameFromUrl(absoluteUrl);
// Handling external link redirection.
if (isExternalLink(absoluteUrl) && (['_blank', '_new'].includes(anchorElement.target) || externalTargetLink())) {
if ((isExternalLink(absoluteUrl) && ['_blank', '_new'].includes(anchorElement.target)) || externalTargetLink()) {
handleExternalLink(e, absoluteUrl);
return;
}