问题原因: 火狐浏览器event报未定义错误
问题分析:该方法只对IE有效,原因是Firefox的window对象没有event属性,所以window.event是不存在的,Firefox只能在事件句柄函数的第一个参数获取事件对象
解决方案:在调用的方法是增加参数event来解决
$("#"+id+"_down").parent().html('<input type="text" οnkeyup="pgeCtrl.pwdCapsLock(\'' + obj.settings.pgeCapsLKOn +'\',\'' + obj.settings.pgeCapsLKOff + '\',true,event)" οnfοcus="'+fos+'pgeCtrl.openProt(\''+winId+'\',this.id);pgeCtrl.pwdCapsLock(\'' + obj.settings.pgeCapsLKOn +'\',\'' + obj.settings.pgeCapsLKOff + '\',null,event);pgeCtrl.setCX(this);'+obj.settings.pgeOnfocus+'" placeholder="' + obj.settings.pgePlaceHolder + '" οnkeydοwn="pgeCtrl.setSX(event,\''+obj.settings.pgeOnkeydown+'\',this);" onclick = "pgeCtrl.setCX(this)" onblur = "pgeCtrl.closeProt(\''+winId+'\',this.id);'+obj.settings.pgeOnblur+'" id = "'+id+'" style="ime-mode:disabled" tabindex="2" class="' + obj.settings.pgeClass + '"/>');
//定义的方法
pwdCapsLock : function(fun1,fun2,flag,event) {
if((navigator.userAgent.toLowerCase().indexOf("firefox"))>-1){// var theEvent = window.event || arguments.callee.caller.arguments[0];
// var srcElement = theEvent.srcElement;
// if (!srcElement){
// srcElement = theEvent.target;
// }
var theEvent =window.event||event;
var keyCode = theEvent.keyCode||theEvent.which; // 按键的keyCode
if(flag) if(keyCode != 20) return;
}else{
var e = event||window.event;
var keyCode = e.keyCode||e.which; // 按键的keyCode
if(flag) if(keyCode != 20) return;
}
var code = 0;
if (!isInstalled) {
code = 0;
}else{
try {
var control = this.pwdGetEById(this.settings.pgeId);
if (this.osBrowser == 10 || this.osBrowser == 11){
var id = this.settings.pgeWindowID;
OUTJSON.id = id,OUTJSON.data.datatype = 14,OUTJSON.data.encrypttype = 0;
datac = this.getEnStr(this.settings.pgeRZRandNum,OUTJSON);
RZCIJSON = {"rankey":this.settings.pgeRZRandNum,"datab":this.settings.pgeRZDataB,"datac":datac};
code = this.pwdGetData(RZCIJSON);
if(code == "1"){
eval("(" + fun1 + ")");
}else if(code == "0"){
eval("(" + fun2 + ")");
}
}else{
return "";
}
} catch (err) { code = 0; }
}
return code;
},