xxxxxxxxxx
<!DOCTYPE html>
<html>
<title>JavaScript alert警告框示例 - 基础教程(div.cn)</title>
<body>
<p>点击按钮显示确认框:</p>
<button onclick="myFunc()">点我试试</button>
<p id="output"></p>
<script>
function myFunc() {
var txt;
var r = confirm("Press a button!");
if (r == true) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
}
document.getElementById("output").innerHTML = txt
}
</script>
</body>
</html>