[whatwg] Can we deprecate alert(), confirm(), prompt() ?

2011-03-01 11:13 EEST: Robert O'Callahan:
> On Tue, Mar 1, 2011 at 6:38 PM, Ojan Vafai <ojan at chromium.org> wrote:
> 
>> FWIW, chromium is planning on experimenting with disallowing modal dialogs
>> during the beforeunload/unload events.
>> http://code.google.com/p/chromium/issues/detail?id=68780
> 
> That sounds fairly unpleasant for users of pages which give "are you sure
> you want to leave this page and lose your data?" warnings.

We already have onbeforeunload that almost does the trick... How about
adding a new property for this that needs to be set before user tries to
unload the page in the first place.

For example:

	window.onbeforeunloadmessage

defaults to an empty string and if this property is set to non-empty
string, then the UA should prompt this message with buttons "Close
anyway" and "Stay on page" (or equivalent) before unloading the document.

This allows for following fixes to current unload and onbeforeunload
features:

- Page script must set this message at the moment the page
  should not be closed without consideration
- UA may display visual clue that a tab should not be closed
  even before the closing is tried
- UA does not need to run any JS code before closing a tab
  because this is only a string that is either empty or not
- UA may disable/stop running JS the moment the user tries to
  close the tab and continue running JS only if user hits
  the "Stay on page" button.

What do you think?

-- 
Mikko

Received on Tuesday, 1 March 2011 06:38:45 UTC