第一种方法:
<head>
<title>Check Score</title>
<script language="JavaScript">
function keyLogin(){
if (event.keyCode==13)
//回车键的键值为13
document.getElementByIdx_x("input1").click();
//调用登录按钮的登录事件
}
</script>
</head>
<body οnkeydοwn="keyLogin();">
<input id="input1" value="登录" type="button" onClick="alert('调用成功!')">
</body>
</body>
第二种方法:
<head>
<script language="JavaScript">
function keyLogin(){
}
</script>
<body οnkeydοwn="keyLogin();">
<input id="input1" value="登录" type="button" onClick="alert('调用成功!')">
</body>
第二种方法:
<script>
function KeyDown()
{
if (event.keyCode == 13)
{
event.returnValue=false;
event.cancel = true;
Form1.btnsubmit.click();
}
}
</script>
使用方法:
<form name="Form1" method="">
用户名:<INPUT TYPE=text SIZE=20 maxlength = 8 οnkeydοwn=KeyDown()>
密码:<INPUT TYPE=password SIZE=20 maxlength = 8 οnkeydοwn=KeyDown()>
<input type="submit" name="btnsubmit" value="提交" />
</form>
function KeyDown()
{
}
</script>
使用方法:
<form name="Form1" method="">
用户名:<INPUT TYPE=text SIZE=20 maxlength = 8 οnkeydοwn=KeyDown()>
密码:<INPUT TYPE=password SIZE=20 maxlength = 8 οnkeydοwn=KeyDown()>
<input type="submit" name="btnsubmit" value="提交" />
</form>