[b][size=medium]HTML[/size][/b]
irfirefox2.0中不支持 window.event.keyCode,
但是我们可以用event.which代替。但是为了使其能更具有普遍的兼容性,最好用[color=red]event.keyCode|| event.which[/color]
[b][u]Keycode对照表 [/u][/b]
[img]http://dl.iteye.com/upload/attachment/0080/3591/f7294617-6f8d-3f62-b558-7e51c23a1041.png[/img]
[img]http://dl.iteye.com/upload/attachment/0080/3593/04da002b-0c19-3fcd-a5eb-60abeb10368c.png[/img]
[img]http://dl.iteye.com/upload/attachment/0080/3595/fa04f9a8-c9ee-3b82-8ddb-ec37ac92e9d2.png[/img]
[img]http://dl.iteye.com/upload/attachment/0080/3597/7d840e78-bf14-39f9-b2a1-5ea872f15e4a.png[/img]
用户名:<input type="text" id="UserAccount" onKeyPress="JumpByEnter(UserPwd)" />
密码:<input name="UserPwd" type="password" onKeyPress="IsEnterKeyPress()">
JavaScript:
JumpByEnter(UserPwd) 函数功能:输入完用户名按回车,焦点转向密码输入框
IsEnterKeyPress()功能:输入完密码并按回车,则登录
function JumpByEnter(NextElement){
var lKeyCode = (navigator.appname=="Netscape")?event.which:window.event.keyCode; //event.keyCode按的建的代码,13表示回车
if ( lKeyCode == 13 ){
NextElement.focus();
}
function IsEnterKeyPress(){
var lKeyCode = (navigator.appname=="Netscape")?event.which:event.keyCode;
if ( lKeyCode == 13 ){
Login();
}
else
return false;
}
irfirefox2.0中不支持 window.event.keyCode,
但是我们可以用event.which代替。但是为了使其能更具有普遍的兼容性,最好用[color=red]event.keyCode|| event.which[/color]
[b][u]Keycode对照表 [/u][/b]
[img]http://dl.iteye.com/upload/attachment/0080/3591/f7294617-6f8d-3f62-b558-7e51c23a1041.png[/img]
[img]http://dl.iteye.com/upload/attachment/0080/3593/04da002b-0c19-3fcd-a5eb-60abeb10368c.png[/img]
[img]http://dl.iteye.com/upload/attachment/0080/3595/fa04f9a8-c9ee-3b82-8ddb-ec37ac92e9d2.png[/img]
[img]http://dl.iteye.com/upload/attachment/0080/3597/7d840e78-bf14-39f9-b2a1-5ea872f15e4a.png[/img]