会员
周边
众包
新闻
博问
闪存
赞助商
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
DODONG
博客园
首页
新随笔
联系
订阅
管理
公告
按下回车表示确定提交
<
body onkeydown
=
"
if (event.keyCode==13) {document.all.button2.click()}
"
>
下面的五种方法都可以帮你解决这种问题
1
.
<
script language
=
javascript
>
function
document.onkeydown()
{
if
(event.keyCode
==
13
)
{
if
(event.srcElement
==
document.getElementById('
<%=
txtEmpCode.ClientID
%>
'))
document.getElementById('
<%=
BtnQry.ClientID
%>
').click();
else
if
(event.srcElement
==
document.getElementById('
<%=
txtDeptCode.ClientID
%>
'))
document.getElementById('
<%=
btnSave.ClientID
%>
').click();
event.cancelBubble
=
true
;
event.returnValue
=
false
;
}
}
</
script
>
2
.
<
body onkeydown
=
"
onkey()
"
bgColor
=
"
#f5efd5
"
MS_POSITIONING
=
"
GridLayout
"
>
<
script language
=
"
javascript
"
>
function
onkey()
{
if
(window.event.keyCode
==
13
)
{
document.all[
"
btnQry
"
].focus();
}
}
</
script
>
3
.
function
document.onkeydown()
{
var
source
=
event.srcElement.id
var
btnid
if
(event.keyCode
==
13
)
{
if
(source
==
"
txtEmpCode
"
) btnid
=
"
btnQry
"
else
if
(source
==
"
txtDeptCode
"
) btnid
=
"
btnSave
"
alert(btnid);
var
btn
=
document.getElementById(btnid);
if
(btn
!=
event.srcElement)
{btn.click();
return
false
;}
}
}
4
.
TextBox1.Attributes.Add(
"
onkeydown
"
,
"
javascript:if (event.keyCode==13) {document.all.
"
&
Button1.ClientID
&
"
.click();return false;}
"
)
5
.
<
script language
=
"
javascript
"
>
<!--
document.onkeydown
=
GlobalKeyDown;
_CMDRETURN
=
13
;
_CMDTAB
=
9
;
_CMDDot1
=
190
;
_CMDDot2
=
110
;
function
GlobalKeyDown()
{
if
(window.event.keyCode
==
_CMDRETURN)
{
if
(event.srcElement.type
!=
"
submit
"
&
event.srcElement.type
!=
"
textarea
"
&
event.srcElement.type
!=
"
button
"
)
{
window.event.keyCode
=
_CMDTAB;
}
else
{
window.event.keyCode
=
_CMDRETURN;
}
}
}
//
-->
</
script
>
posted on
2005-10-22 15:17
DODONG
阅读(
420
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
Powered by:
博客园
Copyright © 2024 DODONG
Powered by .NET 8.0 on Kubernetes