Reputation: 1054
Is there a way to prevent the default behaviour of the Microsoft Edge browser, when I use Ctrl + Left click
on a link?
Edge is opening the link in a new tab, but I want to have my own event for Ctrl + Left click
.
Upvotes: 3
Views: 624
Reputation: 34234
You can assign a click
event handler to your links.
Then, in a handler, you can do e.preventDefault()
in order to prevent default browser action. e.ctrlKey
will tell you if Ctrl button is clicked.
$("a").click(function(e) {
if (e.ctrlKey === true)
{
e.preventDefault();
// your custom actions
}
});
Here is the working JSFiddle demo.
Since you have defined a jquery
tag, I have used this. Of course, it can be easily done in vanilla JS.
Upvotes: 3