Skip to content

Commit 96663fa

Browse files
Open links on a new tab when Ctrl (Win) / Command (macOS) key is pressed
When you're editing a page (&do=edit) and attempt to open another page through the sidebar pressing Ctrl (Windows) or Command (macOS) key, the plug-in attempts to load the clicked page on the current tab, triggering the alert "Changes not saved". This commit adds support for Ctrl (Win)/Command (macOS) key, so if those keys are pressed, instead of opening the link on the current tab, it opens the clicked link on a new tab.
1 parent d5a8614 commit 96663fa

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

script.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,13 @@ jQuery(function(){ // on page load
211211
}
212212

213213
if(node.data.url){
214-
window.location.href = node.data.url;
214+
if (e.ctrlKey || e.metaKey) {
215+
e.stopPropagation();
216+
e.preventDefault();
217+
window.open(node.data.url);
218+
} else {
219+
window.location.href = node.data.url;
220+
}
215221
}
216222
},
217223

0 commit comments

Comments
 (0)