js触发回车事件

// 1.
<script type="text/javascript">
function document.onkeydown(){                //网页内按下回车触发
    if(event.keyCode==13)
    {
        document.getElementById("Button").click();  
        return false;                              
    }
}
</script>

// 2.
<head><meta http-equiv="Content-Type" content="text/html;
charset=gb2312" />
<title>js捕捉回车事件</title><script>
function test(){
if (event.keyCode == 13)   
{       
alert("捕捉住回车提交事件!");   
}
}
</script>
</head>
<body>
<form method="post"> 标题:<input type="text" name="t" onkeydown="test();"/>
</form>
</body>

你可能感兴趣的:(回车事件)