javascript/jquery: responding to a user clicking “ok” on an alert dialog

后端 未结 3 2368
-上瘾入骨i
-上瘾入骨i 2020-12-17 08:19

my code:

alert(\'Some message\');

Question 1:

How to execute code that comes after alert() when user finished interact

3条回答
  •  轮回少年
    2020-12-17 09:04

    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');
    }
    

提交回复
热议问题