[whatwg] Optional non-blocking mode for simple dialogs (alert, confirm, prompt).

Adam Barth w3c at adambarth.com
Sat Feb 26 16:08:41 PST 2011


On Sat, Feb 26, 2011 at 2:29 PM, Ben Rimmington <benrimmington at me.com> wrote:
> <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;
>> }

Of course, that would be a synchronous callback rather than an async one...

Adam


> I'm not sure if navigator.yieldForStorageUpdates() is needed in the non-blocking mode.
>
>


More information about the whatwg mailing list