Skip to content

Commit 97d55cb

Browse files
authored
feat: prevent opening links, unless ctrl or shift clicked (#265)
1 parent 85aeb55 commit 97d55cb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/sandbox.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ function setInnerHTML(node, html) {
6060
newScript.appendChild(doc.createTextNode(text));
6161
prevScript.parentNode.replaceChild(newScript, prevScript);
6262
}
63+
64+
for (let anchor of node.querySelectorAll('a')) {
65+
anchor.addEventListener('click', (e) => {
66+
if (!e.ctrlKey && !e.shiftKey) {
67+
e.preventDefault();
68+
}
69+
});
70+
}
6371
}
6472

6573
function Sandbox() {

0 commit comments

Comments
 (0)