onsubmit - 当用户点击提交按钮
- <!DOCTYPE html>
- <html>
- <head>
- <script>
- function confirmInput() {
- fname = document.forms[0].fname.value;
- alert("Hello " + fname + "!您现在将被重定向到 www.baidu.com");
- }
- </script>
- </head>
- <body>
- <form onsubmit="confirmInput()" action="http://www.baidu.com/">
- 请输入您的姓名:<input id="fname" type="text" size="20">
- <input type="submit">
- </form>
- </body>
- </html>