判断js函数是不是存在typeof

判断js函数是不是存在typeof 【转载】

判断js函数是否存在typeof

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//*==============================================================================*/
//* 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'){

}

文章目录
,