I have requirement of show alert to the user when user try to referesh tab in browser it should get alert "if you alert this page you will loose data" but I am using jquery for this still it is not working .
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
$(window).on('beforeunload', function(){
alert("Don't refresh you will loose your all data?");
//or
confirm("are you sure want to refresh this page !");
});
</script>