参照1
function enter2tab() {
var e = document.activeElement;
var b = (e.tagName == "INPUT"
&& window.event.keyCode == 13
&& ( e.type == "text"
|| e.type == "password"
|| e.type == "checkbox"
|| e.type == "radio")
|| e.tagName=="SELECT");
var a = document.forms[0].elements, n=-1;
for(var i=0; i<a.length; i++)
{
if(a[i]==e) n=i;
if(n>-1 && b && n+1<a.length)
{
if(!a[n+1].disabled)
{
a[n+1].focus();
window.event.keyCode = 0;
window.event.returnValue= false;
return;
}
n=i;
}
}
}
var e = document.activeElement;
var b = (e.tagName == "INPUT"
&& window.event.keyCode == 13
&& ( e.type == "text"
|| e.type == "password"
|| e.type == "checkbox"
|| e.type == "radio")
|| e.tagName=="SELECT");
var a = document.forms[0].elements, n=-1;
for(var i=0; i<a.length; i++)
{
if(a[i]==e) n=i;
if(n>-1 && b && n+1<a.length)
{
if(!a[n+1].disabled)
{
a[n+1].focus();
window.event.keyCode = 0;
window.event.returnValue= false;
return;
}
n=i;
}
}
}
参照2
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<FORM METHOD=POST ACTION="" name="FTYPE">
<INPUT TYPE="button" NAME="button" value="button" onKeyPress="return EnterTo(this)"><br>
<INPUT TYPE="checkbox" NAME="checkbox" value="checkbox" onKeyPress="return EnterTo(this)">checkboxbutton<br>
<INPUT TYPE="checkbox" NAME="checkbox" value="checkbox" onKeyPress="return EnterTo(this)">checkboxbutton<br>
<INPUT TYPE="radio" NAME="radio" value="radiobutton" onKeyPress="return EnterTo(this)">radiobutton<br>
<SELECT NAME="SELECT" onKeyPress="return EnterTo(this)"><OPTION value="SELECT1">SELECT1</OPTION><OPTION value="SELECT2" onKeyPress="return EnterTo(this)">SELECT2</OPTION></SELECT><br>
<INPUT TYPE="submit" NAME="submit" value="submit" onKeyDown="return EnterTo(this)"><br>
<INPUT TYPE="text" NAME="text" value="text" onKeyPress="return EnterTo(this)"><br>
<TEXTAREA NAME="TEXTAREA" ROWS="20" COLS="30" >TEXTAREA</TEXTAREA><br>
<INPUT TYPE="password" NAME="password" value="password" onKeyPress="return EnterTo(this)"><br>
<INPUT TYPE="reset" NAME="reset" value="reset" onKeyPress="return EnterTo(this)"><br>
<INPUT TYPE="file" NAME="file" value="file" onKeyPress="return EnterTo(this)"><br>
<div>fffffffff</div>
</FORM>
<hr>
<SCRIPT LANGUAGE="JavaScript">
<!--
var L = document.FTYPE.elements.length;
for(i=0;i<L;i++){
document.write(document.FTYPE.elements(i).type + "<br>");
}
//-->
</SCRIPT>
</BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
function EnterTo(obj){
var L = document.FTYPE.elements.length;
if (window.event.keyCode == 13){
for(i=0;i<L;i++){
if(obj == document.FTYPE.elements(i)){
if(i+1==L){
document.FTYPE.elements(0).focus();
return false;
}
else{
document.FTYPE.elements(i+1).focus();
return false;
}
}
}
}
}
//-->
</SCRIPT>
</HTML>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<FORM METHOD=POST ACTION="" name="FTYPE">
<INPUT TYPE="button" NAME="button" value="button" onKeyPress="return EnterTo(this)"><br>
<INPUT TYPE="checkbox" NAME="checkbox" value="checkbox" onKeyPress="return EnterTo(this)">checkboxbutton<br>
<INPUT TYPE="checkbox" NAME="checkbox" value="checkbox" onKeyPress="return EnterTo(this)">checkboxbutton<br>
<INPUT TYPE="radio" NAME="radio" value="radiobutton" onKeyPress="return EnterTo(this)">radiobutton<br>
<SELECT NAME="SELECT" onKeyPress="return EnterTo(this)"><OPTION value="SELECT1">SELECT1</OPTION><OPTION value="SELECT2" onKeyPress="return EnterTo(this)">SELECT2</OPTION></SELECT><br>
<INPUT TYPE="submit" NAME="submit" value="submit" onKeyDown="return EnterTo(this)"><br>
<INPUT TYPE="text" NAME="text" value="text" onKeyPress="return EnterTo(this)"><br>
<TEXTAREA NAME="TEXTAREA" ROWS="20" COLS="30" >TEXTAREA</TEXTAREA><br>
<INPUT TYPE="password" NAME="password" value="password" onKeyPress="return EnterTo(this)"><br>
<INPUT TYPE="reset" NAME="reset" value="reset" onKeyPress="return EnterTo(this)"><br>
<INPUT TYPE="file" NAME="file" value="file" onKeyPress="return EnterTo(this)"><br>
<div>fffffffff</div>
</FORM>
<hr>
<SCRIPT LANGUAGE="JavaScript">
<!--
var L = document.FTYPE.elements.length;
for(i=0;i<L;i++){
document.write(document.FTYPE.elements(i).type + "<br>");
}
//-->
</SCRIPT>
</BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
function EnterTo(obj){
var L = document.FTYPE.elements.length;
if (window.event.keyCode == 13){
for(i=0;i<L;i++){
if(obj == document.FTYPE.elements(i)){
if(i+1==L){
document.FTYPE.elements(0).focus();
return false;
}
else{
document.FTYPE.elements(i+1).focus();
return false;
}
}
}
}
}
//-->
</SCRIPT>
</HTML>
参照3
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then 'text3 然后text4
Text4.SetFocus
End If
End Sub
If KeyAscii = 13 Then 'text3 然后text4
Text4.SetFocus
End If
End Sub