我在一个form表单中写了一个button比如<input type="button" onclick="dosomething()">
发现这样写出现了浏览器兼容的问题
在ff下点击这个button是执行这个js函数并且提交表单(跳转到form中action里边的那个页面),在ie6中是只能执行js,我想请问如何实现在或火狐下点击这个button只执行js函数而不提交表单呢?因为我想让提交表单交给type="submit"的input元素
------解决方案--------------------
不可能吧。除非你的dosomething()函数中提交了表单。
------解决方案--------------------
测试了不会啊
------解决方案--------------------
- HTML code
<!DOCTYPE HTML> <html> <head> <meta charset="gbk" /> <title></title> </head> <body> <form action="?"> <input type="button" onclick="dosomething()" value="click" /> <input type="submit" /> </form> <script> function dosomething(){ alert(123) } </script> </body> </html>