<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
window.onbeforeunload = function (e) {
e = window.event;
// For IE and Firefox prior to version 4
return false;
if (e) {
e.returnValue = 'Any string';
}
// For Safari
return 'Any string';
};
$(function () {
$(".btn3").click(function (e) {
window.onbeforeunload = null;//after click this button alert not showm
});
});
</script>
</head>
<body>
<form action="#" method="get">
<input type="submit" value="submit" class="btn" />
</form>
<input class="btn btn1" type="button" value="btn1" />
<input class="btn btn2" type="button" value="btn2" />
<input class="btn btn3" type="button" value="btn3" />
</body>
</html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
window.onbeforeunload = function (e) {
e = window.event;
// For IE and Firefox prior to version 4
return false;
if (e) {
e.returnValue = 'Any string';
}
// For Safari
return 'Any string';
};
$(function () {
$(".btn3").click(function (e) {
window.onbeforeunload = null;//after click this button alert not showm
});
});
</script>
</head>
<body>
<form action="#" method="get">
<input type="submit" value="submit" class="btn" />
</form>
<input class="btn btn1" type="button" value="btn1" />
<input class="btn btn2" type="button" value="btn2" />
<input class="btn btn3" type="button" value="btn3" />
</body>
</html>
No comments:
Post a Comment