I would like to prevent an HTML page refresh (given a variable refreshMode != 1
):
window.onbeforeunload = function(e) {
if(refreshMode == 1){
return;
}else{
// don't do it!
e.preventDefault();
}
};
I have tried e.preventDefault()
and e.stopPropagation()
, but neither appears to be preventing the refresh from submit the request.
Is it possible to do this?