my code:
alert(\'Some message\');
Question 1:
How to execute code that comes after alert()
when user finished interact
var r = confirm("Press a button!");
if (r == true) {
alert("You pressed OK!");
}
else {
alert("You pressed Cancel!");
}
http://jsfiddle.net/rlemon/epJGG/
Question 1:
The alert
method blocks execution until the user closes it:
alert('Some message');
alert('doing something else after the first alert is closed by the user');
Question 2:
use the confirm function:
if (confirm('Some message')) {
alert('Thanks for confirming');
} else {
alert('Why did you press cancel? You should have confirmed');
}
The code after the alert()
call won't be executed until the user clicks ok to the alert, so just put the code you need after the alert()
call.
If you want a nicer floating dialog than the default javascript confirm()
popup, see jQuery UI: floating window