判断js函数是否存在typeof

//*==============================================================================*/
//*   Ajax加载                                                                                                                                                             */
//* 语法:var objLoad=new AjaxLoad()                                                                                                                */
//*       objLoad.Loading(doAction,dataNode[,dataType[,callback[,fullShow]]]);                                               */
//*                                                                                                                                                                              */
//* 参 数:                                                                                                                                                                 */
//*      -doAction[必需的]  执行 URL                                                                                                                        */
//*      -dataNode[必需的]  显示获取内容的容器 ID                                                                                              */
//*      -dataType[可选的]  数据类别[text|xml|body],缺省值 text                                                                         */ 
//*      -callback[可选的]  输出函数[函数对 像]                                                                                                       */
//*      -fullShow[可选的]  显示模式: 缺省值false-单块模式,true-全屏模式                                                         */
//*                                                                                                                                                                              */
//*                                                                                                                                                                              */
//* 输出函数 [callback]:                                                                                                                                         */
//*      可自定义输出函数来格式化所获取的数据,其格式请参加页尾objPrint()函数                                    */
//*                                                                                                                                                                              */
//*==============================================================================*/  
/*此处调用Charset.vbs来解决当dataType='body'时,xmlHttp.responseBody产生的乱码问题                        */
/*请保证Charset.vbs文件与本文件存放在同一路径当中                                                                                    */
var charsetPath=document.getElementsByTagName("script")[document.getElementsByTagName("script").length-1].src.split("?")[0];
charsetPath=charsetPath.replace("Ajax_Load.js","Charset.vbs");
document.write("<script type=\"text/vbscript\" src=\""+charsetPath+"\"></scr"+"ipt>");
//*==============================================================================*/ 
//*                           AjaxLoad begin                                                                                                                         */
//*==============================================================================*/  
function AjaxLoad(){
    /*初始化Ajax                                             */
 function InitAjax(){
  var Ajax=false;
  /*Microsoft*/
  try {
     Ajax = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
     try {
     Ajax = new ActiveXObject("Microsoft.XMLHTTP");
     } catch (E) {
     Ajax = false;
     }
  }/*Mozilla*/
  if (!Ajax && typeof Ajax!='undefined') {
     Ajax = new XMLHttpRequest();
  }
   return Ajax;
 }
 /*---------------------------------------------------------------------------*/    
 /*   判断函数或对像是否存在  一定要添加try catch块,否则不起作用             */
 /*---------------------------------------------------------------------------*/    
 function objExists(objName){
  try{ 
   if(typeof eval(objName)=="undefined"){return false;}
   if(typeof eval(objName)=="object"){return true;}
  }catch(e){
   return false;
  }
 }
 function funExists(funName){
  try{ 
   if(typeof eval(funName)=="undefined"){return false;} 
   if(typeof eval(funName)=="function"){return true;}
  }catch(e){
   return false;
  }
 } 
 /*-----------------------------------------------------------------------*/ 
 var fullShow=false;
 var doAction="";
 var dataType="text";
 var callback=null;
 var dataNode=null;
    var objAjax = new InitAjax();
 this.Loading=function(_doAction,_dataNode,_dataType,_callback,_fullShow){
  try{
   doAction=_doAction;
   dataType=_dataType;
   callback=_callback;
   dataNode=document.getElementById(_dataNode); 
   /**/
   if(!dataNode){alert("参数错误,请输入正确的ID");return false;}
   if(!_fullShow){fullShow=false;}else{fullShow=true; }
   objAjax.open("GET",doAction, true);
   objAjax.onreadystatechange = function(){handleStateChange();};   
   objAjax.setRequestHeader("Accept-charset","gb2312");
   objAjax.setRequestHeader("If-Modified-Since","0");  //禁止缓存
   objAjax.send(null); 
  }catch(e){
  }
 } 
 function handleStateChange(){
  if (objAjax.readyState == 4 && objAjax.status == 200) {
   try{
       var data=getData(dataType,objAjax);
        if(objExists(callback)){
        data=eval(callback+"("+data+");");
    }
    dataNode.innerHTML = data;
   }catch(e){
      alert(e)
   }
  }else{
   var outString="";
   if(!fullShow){
    /*Loading, please wait……|在此处设置显示样式*/
    outString+="<div style='color: #FF0000;font-size: 10pt;'>正在加载,请稍候……</div>";
    dataNode.innerHTML = outString;
   }else{
    outString+="<!-- load start -->";
    outString+="<div id='load' style='position:absolute;z-index:10;top:expression(body.clientHeight/2-60);left:expression(body.clientWidth/2-110); height:120px;width:220px;margin-right: auto;margin-left: auto;text-align: center;color: #FF0000;font-size: 10pt;padding: 5px;line-height: 20px;background-color: #FFFFFF;border-top-width: 1px;border-right-width: 2px;border-bottom-width: 2px;border-left-width: 1px;border-top-style: inset;border-right-style: outset; border-bottom-style: outset;border-left-style: inset;border-top-color: #ECE9D8; border-right-color: #ECE9D8;border-bottom-color: #ECE9D8;border-left-color: #ECE9D8;'>";
    outString+="  <div id='loadLogo' style='margin-top: 30px;margin-right: auto;margin-bottom: 20px;margin-left: auto;'><img src='Images/Wait.gif' width='32' height='32' /></div>";
    outString+="  <div id='loadTitle' style=''>Loading, please wait……</div> ";
    outString+="</div>";
    outString+="<div id='loadMask' style='position:absolute;z-index:1; top:0;left:0; width:expression(body.clientWidth); height:expression(body.clientHeight);background:#999999;filter:Alpha(opacity=60);'></div>";
    outString+="<!-- load end  -->";
    dataNode.innerHTML = outString;    
   }
  }
 }
 function getData(dataType,xmlHttp){
     if(dataType=="xml"){
    return xmlHttp.responseXML;
  }else if(dataType=="body"){
    /*Bytes2Bstr在Charset.vbs中*/
    return Bytes2Bstr(xmlHttp.responseBody);   
  }else if(dataType=="stream"){
    return xmlHttp.responseStream;   
  }else{
    return xmlHttp.responseText;   
  }
 }
 /*-----------------------------------------------------------------------*/ 
}
/*===========================================================================*/
/*                                AjaxLoad end                               */ 
/*===========================================================================*/

/*Charset.vbs文件内容:

'编码处理函数:解决XMLHTTP返回的中文乱码处理

Function Bytes2Bstr(bodyStr)
 strReturn = ""
 For i = 1 To LenB(bodyStr)
  ThisCharCode = AscB(MidB(bodyStr,i,1))
  If ThisCharCode < &H80 Then
     strReturn = strReturn & Chr(ThisCharCode)
  Else
     NextCharCode = AscB(MidB(bodyStr,i+1,1))
     strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
     i = i + 1
  End If
 Next
 Bytes2Bstr = strReturn
End Function

*/

/*---------------------------------------------------------------------------*/ 

/*             输出函数格式如下                                                        */
/*---------------------------------------------------------------------------*/ 
function objPrint(){
  /*在此处格式化数据后,再返回格式化了的数据*/
  //alert("执行了格式化哟")
  return data;
}

 

 

判断父页面函数是否存在

if(typeof(opener.showLicenceList)=='object'){

 

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值