I am currently working on one project in that if user try to refresh current page they will get confirm box with alert Don't refresh page or else you will lose data so if they cancel then he will stay on same page, but my problem is when they click on yes i.e Reload as he click reload one more alert should get you clicked reload now page will reload and data will loss, so how to do this because I am not getting any thing when he click on Reload button.
below I have written script.
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
$(window).on('beforeunload', function(){
return prompt("are you sure want to refresh this page !");
if(true){
alert('You will lose data');
}
else{
alert("Ok continue your work");
}
});
</script>
return prompt()any code after areturnstatement will not be executed