Alex Rivera | Logout

Emulate Javascript 'alert' blocking nature

Asked 2012-11-29T21:44:03.273
20

Is it possible to create a custom modal message which 'blocks' the execution of the script until a user input?

For example, how can you achieve this without using the native window alert / prompt functions?

setInterval(function(){ 
     alert('Click OK to Continue');  // timing stops until user hits ok
},4000);

I know you could have your custom dialog invoke a callback function on user input, but I'm interested in being able to force this blocking behaviour

Edit
Report

1 Answer

-1

No, you can't (at least not in a browser). Javascript APIs are mostly async. alert/prompt are exceptions. However, it's not very hard to work with async prompts and callbacks.

answered 2012-11-29T21:47:09.253

Your Answer