I have javascript code which alerts users before refreshing the page:
<head>
<script>
window.onbeforeunload = function() {
return true;
};
$('#quizsb_f').submit(function() {
$(window).unbind('beforeunload');
});
</script>
</head>
But it is also alerting when a user clicks on the submit button of the page.
I don't want to show any alerts on submitting a form, but I need alert at time of refreshing.
Button Code:
<form method="post" action="qform.php?srn=<?php echo $srn ?>&id=<?php echo $id ?>" enctype="multipart/form-data" class="form-horizontal" id="quizsb_f">
<button class="btn btn-large btn-primary" type="submit" name="btn-submit" id="quizsb">Submit</button>
</form>