JavaScript 确认按钮 【每日一段代码48】

<html>
<head>
<script type="text/javascript">
function show_confirm()
{
var r=confirm("点击按钮!");
if (r==true)
{
alert("你选择确定");
}
else
{
alert("你选择取消");
}
}
</script>
</head>
<body>
<input type="button" onclick="show_confirm()" value="展示确认按钮">
</body>
</html>

【确认框用于使用户可以验证或者接受某些信息。当确认框出现后,用户需要点击确定或者取消按钮才能继续进行操作。如果用户点击确认,那么返回值为 true。如果用户点击取消,那么返回值为 false。语法:confirm("文本")】

原文地址:https://www.cnblogs.com/naokr/p/2396734.html