JSFiddle - React, Tailwind, and code Playground
HTML
<a href="https://qawithexperts.com" id="checkConfirmation">Navigate to other website</a>
JavaScript
var anchorLink = document.getElementById('checkConfirmation');
anchorLink.onclick = function() {
var check = confirm("Are you sure you want to leave?");
if (check == true) {
return true;
}
else {
return false;
}
};