0

I'm looking for a way to pause a javascript function while waiting for the user to make a choice. I would like it to work like prompt, alert or confirm (they pause the script) but I would like to create my own query box in html.

Is there any way that I can achieve this?

4
  • See: stackoverflow.com/questions/2035645/… Commented Jan 18, 2013 at 21:28
  • @MikeChristensen What do you mean by that? Commented Jan 18, 2013 at 21:38
  • @user916276 - See the FAQ - Notably: When you have decided which answer is the most helpful to you, mark it as the accepted answer by clicking on the check box outline to the left of the answer. Commented Jan 18, 2013 at 21:50
  • Related: Sleep in Javascript Commented Mar 9, 2015 at 20:04

1 Answer 1

2

Setup a callback that will be called when the user make the choice then let the javascript end after showing the choices to the user.

Sign up to request clarification or add additional context in comments.

7 Comments

Thanks a lot! Do you know any good tutorial that shows how to write a good callback function?
this is an example w3schools.com/js/tryit.asp?filename=tryjs_events taken from here w3schools.com/js/js_examples.asp which is a nice site
But does a callback really pause the execution of the javascript code?
No, it doesn't. Nothing pauses a JavaScript thread - there's no sleep function. What the callback does is that it waits for a specific action to finish before commencing executing on the code within the callback
the javascript thread pauses when ends. but the javascript engine keeps running if there are callback that may be triggered by events.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.