I made the following script
$(document).ready(function () {
$('html').keydown(function (e) {
if (e.keyCode == 8)
{
ConfirmarVolta();
}
});
});
function ConfirmarVolta() {
if (confirm("Deseja voltar a tela inicial de cadastro de pedido? O progresso no pedido atual será perdido.")) {
location.href = "pedidoInserir.aspx";
} else {
return false;
}
}
And I hoped that by clicking 'cancel' on the popup, the screen would not suffer go back. I separated the trigger function from pressing the backspace key because it is used in another part of the code. How can I cancel the backspace action if the user does not confirm?