高分向高手求救!关于回车跳焦点的问题!

jackingod jackingod 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
项目中需要输入code,按回车自动提交页面。本人做的函数如下:

function testEnterToTab(event,flg) {
var e = event?event:window.event;
if(e.keyCode == 13){
if ('s' == flg) {
doSearchS_Barcode();//提交相关函数
} else if ('b' == flg) {
doSearchB_Barcode();//提交页面相关函数
}
}
}

调用如下:

<html:text name="CollectionLendForm" styleId="s_barcode" property="s_barcode" size="18" maxlength="32" style="width:200px;" onkeydown="testEnterToTab(event, 's');" tabindex="1"/>

可以正常运行。
现在客户要求在输入完code以后,能够给出提示音,类似消息框的报警音。
于是本人又做函数如下:

function tospeakSound() {
var sLen = <%= sLen %>;
var sbarcode = document.forms[0].s_barcode;
if (sbarcode.value.Trim().length == sLen) {
document.getElementsByTagName("bgsound")[0].src = '<%= ctxtPath %>/images/music/ding.wav';
}
}

然后在对应的控件中追加上面这个方法:

<html:text name="CollectionLendForm" styleId="s_barcode" property="s_barcode" size="18" maxlength="32" style="width:200px;" onkeydown="testEnterToTab(event, 's');" onchange="tospeakSound();" tabindex="1"/>

当输入完code焦点离开时,确实发出了提示音,但是当暗回车提交页面时,出现错误如下:
错误: uncaught exception: [Exception... "Cannot modify properties of a WrappedNative" nsresult: "0x80570034 (NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN)" location: "JS frame :: chrome://global/content/bindings/autocomplete.xml :: onxblpopuphiding :: line 834" data: no]

望高手指点,高分求解。
...全文
评论 22
收藏 已收藏
分享
返回顶部
jackingod
JavaScript 87,983 成员 224,681 内容