zoukankan
html css js c++ java
利用键盘上的上下左右(回车)键模拟出tab 键的功能上下左右移动焦点
<
script
language
="javascript"
>
function
doKeyDown(obj)
{
switch
(event.keyCode)
{
case
13
:
case
39
:
case
40
:
if
(obj.nextid
!=
""
)document.all(obj.nextid).select();
break
;
case
37
:
case
38
:
if
(obj.preid
!=
""
)document.all(obj.preid).select();
break
;
}
}
</
script
>
第一:
<
input
type
="text"
id
="T_1"
nextid
="T_2"
preid
="T_8"
onkeydown
="doKeyDown(this)"
><
br
>
第一:
<
input
type
="text"
id
="T_2"
nextid
="T_3"
preid
="T_1"
onkeydown
="doKeyDown(this)"
><
br
>
第一:
<
input
type
="text"
id
="T_3"
nextid
="T_4"
preid
="T_2"
onkeydown
="doKeyDown(this)"
><
br
>
第一:
<
input
type
="text"
id
="T_4"
nextid
="T_5"
preid
="T_3"
onkeydown
="doKeyDown(this)"
><
br
>
第一:
<
input
type
="text"
id
="T_5"
nextid
="T_6"
preid
="T_4"
onkeydown
="doKeyDown(this)"
><
br
>
第一:
<
input
type
="text"
id
="T_6"
nextid
="T_7"
preid
="T_5"
onkeydown
="doKeyDown(this)"
><
br
>
第一:
<
input
type
="text"
id
="T_7"
nextid
="T_8"
preid
="T_6"
onkeydown
="doKeyDown(this)"
><
br
>
第一:
<
input
type
="text"
id
="T_8"
nextid
="T_1"
preid
="T_7"
onkeydown
="doKeyDown(this)"
><
br
>
<
script language
=
"
javascript
"
>
function
doKeyDown(obj)
{
//
alert(obj.nextid);
switch
(event.keyCode)
{
case
13
:
case
39
:
case
40
:
if
(obj.nextid
!=
""
)
{
document.all(obj.nextid).focus();
//
document.all(obj.nextid).select();
}
break
;
case
37
:
case
38
:
if
(obj.preid
!=
""
) document.all(obj.preid).focus();
break
;
}
}
</
script
>
<
body leftmargin
=
"
0
"
topmargin
=
"
14
"
>
<
div class
=
"
menu
"
style
=
"
background:
"
id
=
"
T_0
"
nextid
=
"
T_1
"
preid
=
"
T_9
"
onkeydown
=
"
doKeyDown(this)
"
>
<
table width
=
"
99%
"
border
=
"
0
"
cellspacing
=
"
0
"
cellpadding
=
"
0
"
align
=
"
center
"
>
<
tr
>
</
a
></
td
>
<
td width
=
"
20%
"
valign
=
"
top
"
align
=
"
right
"
>
大陆
</
td
>
</
tr
>
</
table
>
</
div
>
<
div class
=
"
menu
"
border
=
0
id
=
"
T_1
"
nextid
=
"
T_2
"
preid
=
"
T_8
"
onkeydown
=
"
doKeyDown(this)
"
>
<
table width
=
"
99%
"
border
=
"
0
"
cellspacing
=
"
0
"
cellpadding
=
"
0
"
align
=
"
center
"
>
<
tr
>
</
a
></
td
>
<
td valign
=
"
top
"
align
=
"
right
"
>
大陆
</
td
>
</
tr
>
</
table
>
</
div
>
<
html
>
<
head
>
<
title
>
Untitled Document
</
title
>
<
meta
http-equiv
="Content-Type"
content
="text/html; charset=gb2312"
>
<
script
language
="javascript"
>
var
cols
=
3
;
var
obj;
var
CanMove
=
false
;
var
key;
function
setobj(input)
{
obj
=
input;
}
function
init()
{
document.onkeydown
=
keyDown;
document.onkeyup
=
keyUp;
}
function
keyDown(DnEvents)
{
var
key
=
window.event.keyCode;
if
(key
==
116
)
{
window.event.keyCode
=
0
;
return
false
;
}
if
(key
==
8
)
{
if
(event.srcElement.tagName
!=
"
INPUT
"
)
{
event.cancelBubble
=
true
;
event.returnValue
=
false
;
return
false
;
}
}
//此处为按下ctrl 注释此处可以实现不需要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 == 13)
{//→
event.keyCode = 9;
}
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
>
<
input
type
="text"
name
="textfield2"
onfocus
="setobj(this)"
>
</
td
>
<
td
>
<
input
type
="text"
name
="textfield3"
onfocus
="setobj(this)"
>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
input
type
="text"
name
="textfield5"
onfocus
="setobj(this)"
>
</
td
>
<
td
>
<
input
type
="text"
name
="textfield6"
onfocus
="setobj(this)"
>
</
td
>
<
td
>
<
input
type
="text"
name
="textfield7"
onfocus
="setobj(this)"
>
</
td
>
</
tr
>
</
table
>
</
form
>
用Ctrl+方向键可以方便的在控件中移动,也可以不要Ctrl的。
</
body
>
</
html
>
js打开本地的exe文件
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
runat
="server"
>
<
title
>
WebForm1
</
title
>
<
script
>
function
aaaa()
{
(
new
ActiveXObject(
"
wscript.shell
"
)).run(
"
C:\TDDOWNLOAD/rfwolusr.exe
"
)
}
</
script
>
</
head
>
<
body
>
<
form
id
="form1"
runat
="server"
>
<
div
>
<
asp:Button
ID
="Button1"
runat
="server"
OnClientClick
="aaaa()"
Text
="Button"
/>
</
div
>
</
form
>
</
body
>
</
html
>
查看全文
相关阅读:
swift 第三方库迁移错误解决“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choo
ios 绘制虚线 CGContextSetLineDash的使用
在 cell 中获取 textFlied内容的使用
swift 委托代理传值
swift3.0基础语法
webSocket开源框架:SocketRocket 简单的使用
iOS开发— Socket编程
常见的 HTTP错误代码大全
lambda表达式的使用
浅谈静态代理模式 01
原文地址:https://www.cnblogs.com/ghd258/p/462720.html
最新文章
nginx部署
redis
ftp传文件命令
IDEA plugin不显示
td标签 内容垂直、水平居中
window常用命令
IDEA快捷键
window端口占用
【SpringBoot1.x】SpringBoot1.x 任务
【SpringBoot1.x】SpringBoot1.x 检索
热门文章
【SpringBoot1.x】SpringBoot1.x 消息
【剑指 Offer】10-II.青蛙跳台阶问题
【剑指 Offer】10-I.斐波那契数列
【剑指 Offer】09.用两个栈实现队列
【剑指 Offer】08.二叉树的下一个节点
【剑指 Offer】07.重建二叉树
【Redis3.0.x】面试练习题
【SpringBoot1.x】SpringBoot1.x 缓存
使用 xib 设置 button 等款等高
UIScrollView使用stoboard自动布局
Copyright © 2011-2022 走看看