There are many options for dialog replacement.
There are several choices for
alert()/confirm()/prompt(). For notifying the
user of events (e.g. calendaring sites), the
should be used. For obtaining user input, the
HTML <dialog> element
should be used. For XSS proofs-of-concept, devtool’s
console.log(document.origin) can be used.
onbeforeunload, it should be noted that it is already unreliable. As
Ilya Grigorik points out,
“You cannot rely on
unload events to fire on
mobile platforms.” If you need to save state, you should use the
Page Visibility API.
The ability for a page to specify the
onbeforeunload string was
removed in Chrome 51.
(It was also removed by Safari starting with Safari 9.1 and in Firefox 4.)
alert()/confirm()/prompt() dialogs have changed from being app-modal to being
dismissed when their tab is switched from. This
change took place across all channels at the beginning of May 2017.
beforeunload dialogs require a user gesture on the page to allow them to show
starting in Chrome 60.
(This does not change the dispatching of the
beforeunload event.) This aligns
Chromium with Firefox, which made this change with Firefox
alert()/confirm()/prompt() dialog while in fullscreen will cause
fullscreen to be lost
starting in Chrome 61.
prompt() dialogs do not activate their tab. If
prompt() is called from a
background tab, the call returns immediately and no dialog is shown.
took place across all channels at the beginning of May 2017.
alert() dialogs do not activate their tab. If
alert() is called from a
background tab, the call returns immediately. The tab is marked with an indicator
and the user will see the dialog when they switch to the tab. This behavior change
starting in Chrome 64.
Because of these changes, if your site uses dialogs, it is highly recommended that you move to using the earlier-mentioned alternatives so that this will not affect you.