/*---------------------------------------------------------------------------*/
/* 判断函数或对像是否存在 一定要添加try catch块,否则不起作用 */
/* */
/* Javascript 的 typeof可以获取变量的类型,有如下6种返回值: */
/* 1)number; */
/* 2)string; */
/* 3)boolean; */
/* 4)object; */
/* 5)function; */
/* 6)undefined. */
/*---------------------------------------------------------------------------*/
/*对像是否存在*/
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;
}
}
/*ID是否存在*/
function IdExists(idName){
try{
if(document.getElementById(idName)){return true;}else{ return false;
}
}catch(e){
return false;
}
}