en.javascript.info/2-ui/5-loading/02-script-async-defer/window-onbeforeunload.view/index.html
2019-04-02 14:01:44 +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>