Maison > Article > développement back-end > 在下php小白请大牛指教!我写的这个按钮跳转怎么无效啊。急
nbsp;html>
点击后不仅仅执行func(),还会提交表单,这样就造成func()无法执行,因为一旦提交表单就会刷新页面。建议你写在form里 即:
试了还不行啊,还是无法跳转到指定页面…
onsubmit="return false;" form属性
<!doctype html><html><head><meta charset="utf-8"><link rel="stylesheet" type="text/css" href="table_style.css"><title> </title> <script type="text/javascript">/*function func(){ location.href='products.php';}*/</script> </head> <body> <form name="form1" method="post" action="products.php"> <table > <caption><strong>水果售货标记</strong></caption> <tbody> <tr> <th width="36">编号</th> <th width="37">名称</th> <th width="61">规格</th> <th width="54">价格</th> <th width="53">剩余量</th> <th width="111">网址</th> </tr> <tr> <td>1</td> <td>苹果</td> <td>箱/40元</td> <td>10元/斤</td> <td>20斤</td> <td>www.huamin.com</td> </tr> <tr> <td>2</td> <td>桔子</td> <td>框/100元</td> <td>5元/斤</td> <td>60斤</td> <td>www.huamin.com</td> </tr> <tr> <td colspan="6"> <input type='submit' name='button' id='button' value='提交' > </td> </tr> </tbody> </table> </form></body></html>
function func(){
location.href='products.php';
return false;
}
可以把type="submit" 改成type="button" 就不会提交了