confirm 消息对话框通常用于允许用户做选择的动作(包括一个确定按钮和一个取消按钮)。
语法:
confirm(str)
str:在消息对话框中要显示的文本
返回值:
当用户点击"确定"按钮时,返回true
当用户点击"取消"时,返回false
写个例子吧
html
<input name="button" type="button" onclick = "rec()" value="点我弹出对话框">
js
function rec(){
var mymessage = confirm("确定是女士取消是男士"
);
if(maymessage ==
true){
document.write("你是女士!"
);
}else{
document.write("你是男士!"
)
}
}
点确认后页面输出:你是女士!
转载于:https://www.cnblogs.com/2520IT/p/5462274.html
相关资源:javascript实现对话框功能警告(alert 消息对话框)确认(confirm 消息对话框)