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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With