1.最簡單的方法
<head>
<script language=“javascript“ event=“onkeydown“ for =“document“>
<!--
if (event.KeyCode==13)&&event.srcElement.type!='button'&&event.srcElement.type!='submit'&&event.srcElement.type!='reset'&&event.srcElement.type!='')
event.KeyCode=9;
-->
<script>
</head>
2.隨心所欲地控制
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>按鍵跳轉測試</title>
<script language=javascript>
function keypress()
{
akey = event.keyCode;
if(akey ==13)
{
GotoUrl = 'Find.aspx?'+event.srcElement.name+'='+event.srcElement.value;
window.open(GotoUrl);
}
}
function keytab1(event)
{
akey = event.keyCode;
if(akey ==13)
{
document.forms[0].USERADDR.focus();
}
}
function keytab2(event)
{
akey = event.keyCode;
if(akey ==13)
{
document.forms[0].USERPHONE.focus();
}
}
function convertToUpper(textbox)
{
textbox.value = textbox.value.toUpperCase();
}
function checkNum(str)
{
return str.match(/D/)==null
}
</script>
<style>
<!--
body { font-size: 10pt; font-family: 宋體 }
div { border-style: ridge; border-width: 1px; padding: 10px; background-color:#DAF4FE }
-->
</style>
</head>
<body onload="Javascript:document.forms[0].USERID.focus()">
<div style="WIDTH=254px; height:134px">
<FORM method="post">
<b>查詢條件</b>
<HR>
用戶編碼:<INPUT type="text" name="USERID" size="20" onMouseOver="this.focus()" onkeypress="keypress()" onFocus="this.select()"><font face="Webdings">N</font><br>
用戶姓名:<INPUT type="text" name="USERNAME" size="20" onMouseOver="this.focus()" onkeypress="keypress()" onFocus="this.select()"><font face="Webdings">N</font><br>
用戶電話:<INPUT TYPE="text" NAME="USERPHONE" onMouseOver="this.focus()" onChange="convertToUpper(this)" onkeypress="keytab1(event)" onFocus="this.select()"><br>
用戶地址:<INPUT TYPE="text" NAME="USERADDR" onMouseOver="this.focus()" onChange="convertToUpper(this)" onkeypress="keytab2(event)" onFocus="this.select()">
</FORM>
</div>
</body>
</html>