显示确认框

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function show_confirm()
  5. {
  6. var r=confirm("Press a button!");
  7. if (r==true)
  8. {
  9. alert("You pressed OK!");
  10. }
  11. else
  12. {
  13. alert("You pressed Cancel!");
  14. }
  15. }
  16. </script>
  17. </head>
  18. <body>
  19.  
  20. <input type="button" onclick="show_confirm()" value="Show a confirm box" />
  21.  
  22. </body>
  23. </html>