JSFiddle - React, Tailwind, and code Playground
HTML
<form>
<input type='button' value='Go Back' onclick='goBack()' />
</form>
JavaScript
var goBack = function() {
history.back();
};
window.onbeforeunload = function(e) {
alert("In onbeforeunload");
var result = confirm("Continue to go back?");
if(result){
alert("you are going back");
}else{
alert("you are not going back");
}
return result;
};