读书人

回车触发按钮的单击有关问题,

发布时间: 2012-01-12 22:11:58 作者: rapoo

回车触发按钮的单击问题,急

page_load

LoginBtn.Attributes.Add( "onkeydown ", "return confrm(); ");


js里面

function confrm()
{
if(event.keyCode==13)
{
document.all.LoginBtn.click();
}


}

怎么不触发回车啊,,,
我用的是母版页




[解决办法]
onkeyup
[解决办法]
<SCRIPT>
function checkKey()
{
if (window.event.shiftKey) // checks whether the SHIFT key
// is pressed
{
txtOutput.value = "true "; // returns TRUE if SHIFT is pressed
// when the event fires
}
}
</SCRIPT>
</HEAD>
<BODY>
<P> Press the SHIFT key while pressing another key. <BR>
<INPUT TYPE=text NAME=txtEnterValue onkeypress= "checkKey() ">
<P> Indicates "true " if the shift key is used. <BR>
<INPUT TYPE=text NAME=txtOutput>
</BODY>
[解决办法]
-_-!!!只是给你个例子,你可以写成
this.txtEmail.Attributes.Add( "onkeyup ", "javascript:confrm(); ");

读书人网 >C#

热点推荐