就是我 现在需要暂时 覆盖掉系统的方法
window.showModalDialog()这样子覆盖的:
window.showModalDialog = function({参数}){
    //我需要判断其中一个 参数 让我使用我覆盖了的系统方法 还是我自己写的方法
   if(pram1){
      //如果成立我要调用 系统的那个 
      window.showModelDialog(......);
   }else{
     //不成立 就调用自己写的代码
   }
}
就是在条件成立的时候  我需要再次调用 那个被我覆盖的 方法怎么做呢?
javascriptfunctionshowModelDialogjs系统方法覆盖

解决方案 »

  1.   

    用代理模式就行。参考下面原理详见:http://stackoverflow.com/questions/1729501/javascript-overriding-alert    <script type="text/javascript">
            (function() {
                var proxied = window.showModalDialog;
                window.showModalDialog = function() {
                    if (true) {
                         return proxied.apply(this, arguments);
                    }
                    else {
                       alert("Do your works");
                    }
                };
            })();        window.showModalDialog("http://www.baidu.com", "", "dialogWidth=600px;dialogHeight=300px");
        </script>
      

  2.   

    //把系统方法事先保留下再覆盖
    window._showModalDialog = window.showModalDialog;
    window.showModalDialog = function({参数}){
        //我需要判断其中一个 参数 让我使用我覆盖了的系统方法 还是我自己写的方法
       if(pram1){
          //如果成立我要调用 系统的那个 
          window._showModalDialog(......);
       }else{
         //不成立 就调用自己写的代码
       }
    }