<!DOCTYPE html>charset="utf-8"W3Cschool教程(w3cschool.cn)点击按钮,显示确认框。onclick="myFunction()"点我id="demo"function myFunction(){var x;var r=confirm("按下按钮!");if (r==true){x="你按下了\"确定\"按钮!";}else{x="你按下了\"取消\"按钮!";}document.getElementById("demo").innerHTML=x;}