New course! Every coder should learn Generative AI!
Try a free lesson0
how can we add alert message when user want to reload the page?
when user fill the form and data isn't save then how to prevent from reloading the page
2 Answers
+ 2
var alert = confirm("The Form Data are not Saved. Do You Still Want to Reload The page?")
if(alert==true){
}
else{
}
+ 1
Try this
window.onbeforeunload = function(e) {
return confirm("Do you really want to reload the page?");
};