如何用Ctrl键代替Tab键
用户想用Ctrl键实现焦点跳转
以前曾经用回车键代替Tab键
if(window.event.keyCode == 13)
{
window.event.keyCode = 9;
}
本以为将键值改为17就可以了
想不到报 "拒绝访问 "错误信息
------解决方案--------------------ctrl 存在组合用法,无法替代!
用回车吧!
<script language= "javascript " event= "onkeydown " for= "document ">
// 将 Enter 键 设置为 Tab 键
if ( event.keyCode == 13 )
{
event.keyCode = 9;
}
</script>
------解决方案-------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<html>
<head>
<title> New Document </title>
<meta name= "Generator " content= "EditPlus ">
<meta name= "Author " content= " ">
<meta name= "Keywords " content= " ">
<meta name= "Description " content= " ">
</head>
<body>
<form method=post action= " ">
<input type= "text " name= " ">
<input type= "text " name= " ">
<input type= "text " name= " ">
</form>
</body>
</html>
<script language= "JavaScript ">
<!--
document.onkeydown = function()
{
var obj = event.srcElement;
for(var i=0;i <document.forms[0].elements.length;i++){
if(document.forms[0].elements[i]==obj){
if (window.event.ctrlKey){//→
if(i <document.forms[0].elements.length-1){ document.forms[0].elements[i+1].focus(); }
}
}
}
}
//-->
</script>
------解决方案--------------------上面代码即可
------解决方案-------------------- <html>
<head>
<title> test </title>
<script type= "text/javascript ">
document.onkeyup = function(){
try{
if(event.keyCode == 17){
event.keyCode = 9;
var WshShell = new ActiveXObject( "Wscript.Shell ");
WshShell.SendKeys( "{TAB} ");
}
}catch(e){
}
}
</script>
</head>
<body>
<input type= "text " id= "xxx "> <input type= "text "> <input type= "text "> <input type= "text "> <input type= "text "> <input type= "text ">
</body>
</html>