One way to display a confirmation message when a user tries to leave the current page is by using this method:
window.addEventListener("beforeunload", function (e) {
var confirmationMessage = "Are you sure you want to leave?";
e.returnValue = confirmationMessage; // Gecko, Trident, Chrome 34+
return confirmationMessage; // Gecko, WebKit, Chrome <34
});
This also applies to clicking on links, which is expected behavior as it involves leaving the page.
Is there a specific Javascript technique to prevent this confirmation message from appearing when clicking on hyperlinks, similar to what other websites have implemented?