在ASP中有方向键控制光标 就是在ASP中用方向键控制光标 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在页面中嵌js代码可以,你试试这个,看看是不是你想要的,用ctrl+方向键就可以移动。<html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><script language="javascript">var cols=4;var obj;var CanMove=false;var key;function setobj(input){ obj=input;//捕获当前控件对象;}//初始化,用KeyDown和KeyUp方法改写原来的onkeydown和onkeyup方法;function init(){ document.onkeydown=keyDown; document.onkeyup=keyUp;}function keyDown(DnEvents){ var key=window.event.keyCode; if(key==116){ window.event.keyCode=0;//屏蔽F5(刷新)键; return false; } if(key==8){ if(event.srcElement.tagName!="INPUT"){ event.cancelBubble = true;//如果控件当前类型为“input”,屏蔽退格键; event.returnValue = false; return false; } } //在按下Ctrl键时,对方向键进行侦听,并且是光标在各个控件中移动; var IsCtrl=window.event.ctrlKey; if(!IsCtrl){ return; } for(var i=0;i<document.forms[0].elements.length;i++){ if(document.forms[0].elements[i]==obj){ if (key == 37){//← if(i>0){ document.forms[0].elements[i-1].focus(); } } if (key == 38){//↑ if(i>cols-1){ document.forms[0].elements[i-cols].focus(); } } if (key == 39){//→ if(i<document.forms[0].elements.length-1){ document.forms[0].elements[i+1].focus(); } } if (key == 40){//↓ if(i<document.forms[0].elements.length-cols){ document.forms[0].elements[i+cols].focus(); } } } }}function keyUp(UpEvents){ return false;}</script></head><body bgcolor="#FFFFFF" text="#000000" onload="init()"><form><table border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td> <input type="text" name="textfield" onfocus="setobj(this)"> </td> <td> <select name="textfield2" onfocus="setobj(this)"><option>1<option>2</select> </td> <td> <input type="radio" name="textfield3" onfocus="setobj(this)">radio </td> <td> <input type="radio" name="textfield3" onfocus="setobj(this)">radio </td> </tr> <tr> <td> <input type="text" name="textfield5" onfocus="setobj(this)"> </td> <td> <input type="checkbox" name="check1" onfocus="setobj(this)">check1 </td> <td> <input type="checkbox" name="check2" onfocus="setobj(this)">check2 </td> <td> <input type="text" name="textfield8" onfocus="setobj(this)"> </td> </tr></table></form>用Ctrl+方向键可以方便的在控件中移动</body></html> 不错,挺好的,如果不按Ctrl键就更好了,谢谢! 问一个关于JS获取URL参数的问题 ●●如何使用数值处理函数取得指定小数位数的数据? div透明度 有一个大的div 里面包含一个小的div 只想让大的透明 小的不透明 梅花雨的Calendar.js在ASP.NET2.0中使用为什么会出错?谁能帮忙解决? 如何用js做个像csdn.net首页上的tab控件! 有点累,但挺有乐子--散分 自定义Image对象的显示,在线等! 操纵SESSION!!!急!!!! 不好意思在问相同问题... 如何让ie不再弹出activex控件可能不安全的对话框? 返回一个页面并刷新这个页面,该怎么办? 怎么样做一个“保存”的链接。
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
var cols=4;
var obj;
var CanMove=false;
var key;
function setobj(input){
obj=input;//捕获当前控件对象;
}//初始化,用KeyDown和KeyUp方法改写原来的onkeydown和onkeyup方法;
function init(){
document.onkeydown=keyDown;
document.onkeyup=keyUp;
}
function keyDown(DnEvents){
var key=window.event.keyCode;
if(key==116){
window.event.keyCode=0;//屏蔽F5(刷新)键;
return false;
}
if(key==8){
if(event.srcElement.tagName!="INPUT"){
event.cancelBubble = true;//如果控件当前类型为“input”,屏蔽退格键;
event.returnValue = false;
return false;
}
}
//在按下Ctrl键时,对方向键进行侦听,并且是光标在各个控件中移动;
var IsCtrl=window.event.ctrlKey;
if(!IsCtrl){
return;
}
for(var i=0;i<document.forms[0].elements.length;i++){
if(document.forms[0].elements[i]==obj){
if (key == 37){//←
if(i>0){
document.forms[0].elements[i-1].focus();
}
}
if (key == 38){//↑
if(i>cols-1){
document.forms[0].elements[i-cols].focus();
}
}
if (key == 39){//→
if(i<document.forms[0].elements.length-1){
document.forms[0].elements[i+1].focus();
}
}
if (key == 40){//↓
if(i<document.forms[0].elements.length-cols){
document.forms[0].elements[i+cols].focus();
}
}
}
}}function keyUp(UpEvents){
return false;
}
</script>
</head><body bgcolor="#FFFFFF" text="#000000" onload="init()">
<form>
<table border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<input type="text" name="textfield" onfocus="setobj(this)">
</td>
<td>
<select name="textfield2" onfocus="setobj(this)">
<option>1
<option>2
</select>
</td>
<td>
<input type="radio" name="textfield3" onfocus="setobj(this)">radio
</td>
<td>
<input type="radio" name="textfield3" onfocus="setobj(this)">radio
</td>
</tr>
<tr>
<td>
<input type="text" name="textfield5" onfocus="setobj(this)">
</td>
<td>
<input type="checkbox" name="check1" onfocus="setobj(this)">check1
</td>
<td>
<input type="checkbox" name="check2" onfocus="setobj(this)">check2
</td>
<td>
<input type="text" name="textfield8" onfocus="setobj(this)">
</td>
</tr>
</table>
</form>
用Ctrl+方向键可以方便的在控件中移动
</body>
</html>