Beispiel:JS-Event-onbeforeunload.html
Aus SELFHTML-Wiki
<!DOCTYPE html> <html lang="de"> <head>
<meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0;" /> <link rel="stylesheet" media="screen" href="./Beispiel:Grundlayout.css" /> <title>Beispiel: beforeunload Event</title>
</head>
<body>
Beispiel: beforeunload Event
<main>
Verlasse die Seite, damit der beforeunload-Event-Handler ausgelöst wird.
- <a href="https://wiki.selfhtml.org/wiki/Startseite">Wiki</a>
- <a href="https://blog.selfhtml.org/">Blog</a>
- <a href="https://forum.selfhtml.org/">Forum</a>
</main>
<script async>
document.addEventListener('DOMContentLoaded', function () {
window.addEventListener('beforeunload', function(event) {
event.returnValue = 'Ihre individuelle Fehlermeldung ...';
});
});
</script>
</body> </html>