网页中设置默认回车按钮
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>a.htm </title>
<script>
document.onkeydown=function() //网页内按下回车触发
{
if(event.keyCode==13)
{
document.getElementById("bbb").onclick();
return false;
}
}
</script>
</head>
<body>
<form name=form1>
<input type="text" value="" id="aaa" name="aaa" onclick="alert('1提交')">
<input type="button" value="" id="bbb" name="bbb" onclick="alert('2提交')">
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>a.htm </title>
<script>
document.onkeydown=function() //网页内按下回车触发
{
if(event.keyCode==13)
{
document.getElementById("bbb").onclick();
return false;
}
}
</script>
</head>
<body>
<form name=form1>
<input type="text" value="" id="aaa" name="aaa" onclick="alert('1提交')">
<input type="button" value="" id="bbb" name="bbb" onclick="alert('2提交')">
</form>
</body>
</html>