javascript / jquery:响应用户点击“ok”在警报对话框上 [英] javascript/jquery: responding to a user clicking "ok" on an alert dialog

查看:100
本文介绍了javascript / jquery:响应用户点击“ok”在警报对话框上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码:

alert('Some message');

问题1:

如何执行

问题2:

如何检测用户是否按确定取消在警报框?

How to detect if user pressed OK or Cancel on alert box ?

推荐答案

问题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');

问题2:

a href =https://developer.mozilla.org/en/window.confirm =noreferrer> 确认 功能:

use the confirm function:

if (confirm('Some message')) {
    alert('Thanks for confirming');
} else {
    alert('Why did you press cancel? You should have confirmed');
}

这篇关于javascript / jquery:响应用户点击“ok”在警报对话框上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆