From c24cc543d0b396948329c38ff2a17176b02be0b7 Mon Sep 17 00:00:00 2001 From: sight <1453017105@qq.com> Date: Wed, 14 Jun 2023 18:46:38 +0800 Subject: [PATCH] prevent `a` tag from jumping to another tab when `href="JavaScript: void (0)"` --- src/output/srcdoc.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/output/srcdoc.html b/src/output/srcdoc.html index c2b939d6..3261a45c 100644 --- a/src/output/srcdoc.html +++ b/src/output/srcdoc.html @@ -80,7 +80,7 @@ while (el && el.nodeName !== 'A') el = el.parentNode; if (!el || el.nodeName !== 'A') return; - if (el.hasAttribute('download') || el.getAttribute('rel') === 'external' || el.target) return; + if (el.hasAttribute('download') || el.getAttribute('rel') === 'external' || el.target || el.href.startsWith('javascript:')) return; event.preventDefault();