Javascript: Pause program flow until button clicked
<p>Good afternoon chaps..</p>

<p>I'm trying to create a function in Javascript that generates an on screen dialog similar to the msgbox function in VB/VBA.  I've so far managed to code the msgbox function in Javascript so that when it is called it dynamically creates a dialog on screen.</p>

<p>It works like this:-</p>

<pre><code>if (msgbox("Do you want to continue", YesNo) == Yes) {
      //Do something here
}
</code></pre>

<p>What I would like to know is this - is there any way I can halt/pause the flow in code until one of the buttons in my dynamically generated dialog is pressed?  I don't want the 'Do Something here' bit or any other following code to run until a user has clicked the 'Yes' button in my dialog.</p>

<p>(NOTE:  YesNo and Yes, in the example above are constants.   The dialog works perfectly up to this point I just need to figure how to stop flow until a button is pressed without overcomplicating things).</p>

<p>Mat</p>
