confirm消息框教程
弹出一个对话框,让用户确认是否执行操作,常在删除按钮上。
- <html>
- <head>
- <script type="text/javascript">
- function disp_confirm()
- {
- var r=confirm("Press a button")
- if (r==true)
- {
- document.write("You pressed OK!")
- }
- else
- {
- document.write("You pressed Cancel!")
- }
- }
- </script>
- </head>
- <body>
- <input type="button" onclick="disp_confirm()" value="Display a confirm box" />
- </body>
- </html>
’\n’ 可以用来换行,相当于html里的<br />
- <html>
- <head>
- <script type="text/javascript">
- function confirmAdd() {
- var msg = "你好\n确认要修改收件地址?";
- if (confirm(msg)==true){
- return true;
- }else{
- return false;
- }
- }
- </script>
- </head>
- <body>
- <a href="" onclick="javascript:return confirmAdd()">修改收件地址</a>
- </body>
- </html>
Tags: JavaScript 06月 13th, 2008 Posted in JavaScript