我的代码:
alert('Some message');
问题1:
当用户完成与警告框的交互时,如何执行alert()
之后的代码?
问题2:
如何检测用户在警告框上是否按下了OK
或Cancel
?
发布于 2011-09-02 03:34:04
问题1:
alert
方法会阻止执行,直到用户将其关闭:
alert('Some message');
alert('doing something else after the first alert is closed by the user');
问题2:
使用confirm
函数:
if (confirm('Some message')) {
alert('Thanks for confirming');
} else {
alert('Why did you press cancel? You should have confirmed');
}
发布于 2011-09-02 03:36:30
var r = confirm("Press a button!");
if (r == true) {
alert("You pressed OK!");
}
else {
alert("You pressed Cancel!");
}
https://stackoverflow.com/questions/7275512
复制相似问题