confirm消息框教程

弹出一个对话框,让用户确认是否执行操作,常在删除按钮上。

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

 ’\n’ 可以用来换行,相当于html里的<br />

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function confirmAdd() {
  5.     var msg = "你好\n确认要修改收件地址?";
  6.     if (confirm(msg)==true){
  7.     return true;
  8.     }else{
  9.     return false;
  10.     }
  11. }
  12. </script>
  13. </head>
  14. <body>
  15. <a href="" onclick="javascript:return confirmAdd()">修改收件地址</a>
  16.  
  17. </body>
  18. </html>

 

Tags: 06月 13th, 2008 Posted in JavaScript

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Powered by WordPress | Blue Weed by Blog Oh! Blog | Entries (RSS) and Comments (RSS).