日期:2014-05-17  浏览次数:21070 次

submit为什么会单击2次,button就单击一次
<html>
<body>
<center>
<input type="submit" id="Bw" value="按一下" onclick="alert(1)">
<hr width="600" align="center">  
</body>
<script language="javascript" type="text/javascript" defer=true>
function a()
{
if(event.keyCode==13)  
Bw.click();

}
document.onkeydown = a;
</script>
</html>

代码如上,如果按回车,type=“submit”会弹2次窗口,type=“button”只弹一次

------解决方案--------------------
探讨

那为什么“按回车,type=“submit”会弹2次窗口,type=“button”只弹一次”
有谁知道