<script type="text/javascript" language="javascript">
function document.onkeydown()
{ if ((event.keyCode == 13) && (event.srcElement == document.getElementById("txtUserPassword")))
{ var btn = document.getElementById("btnLogin");
btn.focus();
btn.click();
}
}
</script>
其中:txtUserPassword是捕捉回车的控件,它可以是文本框,也可以是下拉列表等可以获取焦点的输入控件;
btnLogin是当文本框捕捉到回车后自动触发的按钮控件.
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)