First of all I have checked many similar questions on here and other resources, but I'm still unable to find the solution I require. I have a button that links to a specific page within my application and I also have a confirm() box that asks if the user wants to continue, if they click ok then the next page should be loaded, if they click cancel the new page should not load, as if the button was never clicked at all. Below is my HTML for the button:
<a href="http://localhost:9000/index">
<button onclick="myFunction()" type="button" class="btn btn-outline-primary btn-lrg" style="font-size:20px;">CANCEL</button>
</a>
And now my JS for the confirm box:
<script>
function myFunction() {
if (confirm("Are you sure you wish to cancel this configuration?")) {
return true;
} else {
return false;
}
}
</script>