en.javascript.info/2-ui/10-loading/02-script-async-defer/window-onbeforeunload.view/index.html
Ilya Kantor 0873d43d72 up
2019-03-26 23:16:23 +03:00

19 lines
378 B
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script>
function setHandler() {
window.onbeforeunload = function() {
return "There are unsaved changes. Leave now?";
};
}
</script>
<button onclick="setHandler()">Set window.onbeforeunload</button>
<a href="http://example.com">Leave for EXAMPLE.COM</a>
</body>
</html>