how to use confirm function with sweetalert in JavaScript

I got a tag that calls function called cancel() in HTML.

<a onclick="return cancel();" href="<%= request.getContextPath()%>/views/pay/user/plan.jsp"></a>

This is how function cancel() looks like in JavaScript.

function cancel() { 
    return confirm("My Message");

If I hit ok button, the page should go back to the designated page.
Or If I hit cancel button, the page should be stay at the same page.

The codes above works fine as I expected except the design.

I want to apply Sweetalert (whatever its version is one or two) to my confirm window.
However, as I far as I searched, I could only find things that confirm ‘yes’ button never makes the page moves to the designated one.

I wonder Sweetalert is literally for plain alert?

Leave a Comment