+ -
当前位置:首页 → 问答吧 → JS 关于this的一点疑问 请指教!

JS 关于this的一点疑问 请指教!

时间:2011-08-29

来源:互联网

window.onload=function(){
       MyIEL_Editor=new IEL_Editor("MyIEL_Editor");
}
IEL_Editor.prototype.prepareSubmit = function (){
       
       if (!oLinkField) {return;}
       var oForm = oLinkField.form;
       if (!oForm) {return;}
       if(this.isMSIE()){
              oForm.attachEvent("onsubmit", this.AttachSubmit);
       }else{
              oForm.addEventListener("submit", this.AttachSubmit);
       }
}

IEL_Editor.prototype.AttachSubmit = function (){
       try{
              if (!oLinkField) {return false;}
              var oForm = oLinkField.form;
              if (!oForm) {return false;}
              
              if(MyIEL_Editor.sCurrMode == "CODE"){
                     MyIEL_Editor.toggleMode("EDIT");
              }
              return true;
       }catch(err){
              alert("错误:" + err.description);
              return false;
       }
}
怎么样才能把 IEL_Editor.prototype.AttachSubmit 函数中的MyIEL_Editor替换成this
因为直接用this.sCurrMode返回的是undefined

作者: dabpop139   发布时间: 2011-08-29

没人可以帮忙指点一下吗!!没人可以帮忙指点一下吗!!没人可以帮忙指点一下吗!!

作者: dabpop139   发布时间: 2011-08-31

人家函数里面根本没用this你怎么替换,如果非要替换你就CTRL+F把里面的代码改成this好了

作者: sophiasmth   发布时间: 2011-08-31

少了个函数

作者: lifeseato   发布时间: 2011-08-31