[X]

Confirm Before Leaving

windows and alerts 1999 partly

Asks Are you sure you want to leave? when the visitor navigates away.

In 2026: Partly works. Browsers still fire the event but they ignore your message and show their own generic wording, and they refuse to prompt at all unless the visitor has interacted with the page.

Where it came from: Microsoft Internet Explorer 4 onbeforeunload, 1997. Standardised much later. MDN

<script language="JavaScript">
window.onbeforeunload = function (e) {
  var msg = "Are you sure you want to leave? Don't forget the guestbook!";
  (e || window.event).returnValue = msg;   // browsers ignore the text now
  return msg;
};
</script>
sandboxed demo · breaks nothing but itselfrestart

More in windows and alerts

all 9 in windows and alerts › · the whole library ›