监听回车事件

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>监听回车事件</title>
</head>

<body>
<script language="javascript">
document.onkeydown=function(eventTag){
    var event=eventTag||windows.event;
    var e=event.srcElement||event.target;
}
document.onkeydown=keyDown
function keyDown(e){
    if((e ? e.which : event.keyCode)==13 ){
        document.getElementById("fy_login").click();
        return false;
    }
}
</script>
<form action="http://www.baidu.com" method="post">
<input type="text"  name="sd" />
<input type="button" id="enter" value="enter" onclick="alert('enter');"/>
</form>
</body>
</html>

你可能感兴趣的:(JavaScript,XHTML,function,action,button,login)