I am developing one project so in that I need if user try to refresh page using f5,ctrl+r then prompt will ask if you refresh page all your data will loss if click yes one more alert should get and if click cancel on this case also alert should get but I am not getting any alert if click on ok or cancel button in prompt box.
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script>
$(window).on('beforeunload', function(){
return aa=confirm("are you sure want to refresh this page !");
if(aa===true){
alert('You will loose your data');
}
else{
alert("Ok continue your work");
}
});
<script>