js判断页面中的某个函数是否存在

来源:互联网 发布:fedora ubuntu suse 编辑:程序博客网 时间:2024/06/05 10:26

 function funExists(funName){
  try{ 
   if(typeof eval(funName)=="undefined"){return false;} 
   if(typeof eval(funName)=="function"){return true;}
  }catch(e){
   return false;
  }
 } 

 

对于当前窗口的某个函数,可以直接用,比如函数change,则可以用funExists(change);

对于父窗口,则可以使用这样的形式判断funExists(window.opener.change),其他以此类推


原创粉丝点击