onkeypress监听不到事件

Lyn_0629 Lyn_0629 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
JSP代码如下:

<form>
<div class="x_input">
<p><input name="userCode" value="" type="text" id="user.USER_CODE" style="font-size:12px; font-family:Arial;" />
</p>
<p style="margin-top:4px;"><input name="password" value="" type="password" id="user.PASSWORD" style="font-size:12px; font-family:Arial;" >
<span style="margin-left:12px;">
<input id="SubId" type="button" onclick="login();" onkeypress="login();" style="width: 67px; height: 22px; background: url(images/x_login.png); border: 0px;"/>
</span>
</p>
</div>
</form>

javascript函数如下:

<script type="text/javascript">
function login(){
var userCode=document.all.userCode.value;
var password=document.all.password.value;
Ext.Ajax.request({
method:'POST',
url:'loginUser',
params:{"user.USER_CODE":userCode,"user.PASSWORD":password},
success:function(response, options){
var respText = Ext.util.JSON.decode(response.responseText);
if(respText.msg=="登录成功!"){
var data = respText.data;
var userName=respText.userName;
var userId=respText.userId;
var topicNames = new Array();
var topicIds = new Array();
if (typeof(data) != "undefined" && data.length > 0)
{
for(var i=0;i<data.length;i++)
{
topicNames.push(data[i]["topic_name"]);
topicIds.push(data[i]["topic_id"]);
}
}

var f=document.createElement("form");
f.action=rootPath+"/IasManager.jsp";
f.method="post";//指定为post
f.innerHTML="<input type='hidden' name='userName' value='"+userName+"'/>;"+
"<input type='hidden' name='userId' value='"+userId+"'/>;"+
"<input type='hidden' name='topicNames' value='"+topicNames+"'/>;"+
"<input type='hidden' name='topicIds' value='"+topicIds+"'/>";
document.appendChild(f);
f.submit();

} else{
Ext.MessageBox.minWidth = 150;
Ext.Msg.alert('提示',respText.msg);
}
},
failure:function(response, options){
Ext.MessageBox.minWidth = 120;
Ext.Msg.alert('提示','操作失败。');
}

});
}

</script>

onclick就有用,而onkeypress就不好用,分不够,菜鸟求指点!
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
Lyn_0629
Web 开发 81,108 成员 341,721 内容