当前位置: 代码迷 >> ASP >> submit为何会单击2次,button就单击一次
  详细解决方案

submit为何会单击2次,button就单击一次

热度:183   发布时间:2012-09-05 15:19:34.0
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”只弹一次”
有谁知道
  相关解决方案