[whatwg] Optional non-blocking mode for simple dialogs (alert, confirm, prompt).
Ben Rimmington
benrimmington at me.com
Sat Feb 26 14:29:50 PST 2011
<http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#simple-dialogs>
An optional callback parameter could be added to the simple dialogs API:
> result = window.alert(message, [callback]);
>
> result = window.confirm(message, [callback]);
>
> result = window.prompt(message, [default], [callback]);
If the callback argument is recognised as a function value:
* the result is the supplied callback;
* the callee returns without waiting for user input;
* the callback is invoked after the dialog is dismissed.
Otherwise [see current spec]:
* the callee simply ignores the callback argument;
* the script is paused until the dialog is dismissed;
* the result is undefined, boolean, string or null.
For user agents that don't support the updated API:
> function promptWrapper(message, default, callback) {
> var result = window.prompt(message, default, callback);
> if (callback && (typeof callback === "function")) {
> if (result !== callback) {
> callback(result);
> }
> return callback;
> }
> return result;
> }
I'm not sure if navigator.yieldForStorageUpdates() is needed in the non-blocking mode.
More information about the whatwg
mailing list