my code:
alert('Some message');
Question 1:
How to execute code that comes after alert()
when user finished interacting with alert box?
Question 2:
How to detect if user pressed OK
or Cancel
on alert box ?
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');
}