javascript 自帶的確認框confirm()方法

原來 html 除了自帶alert()以外,還有一個 確認框的。html

http://www.w3school.com.cn/jsref/met_win_confirm.aspcode

confirm("Press a button!");htm

function show_confirm()
{
var r=confirm("Press a button!");
if (r==true)
  {
  alert("You pressed OK!");
  }
else
  {
  alert("You pressed Cancel!");
  }
}
</script>
</head>
<body>

<input type="button" onclick="show_confirm()" value="Show a confirm box" />
相關文章
相關標籤/搜索