有个方法:
如果当前页面有test这个方法,则调用;没有,则不处理。
首先要要判断test是否为空:
如果为空,则不需进行处理;不为空,继续判断是不是方法:
最后代码如下:
function test(){
}
如果当前页面有test这个方法,则调用;没有,则不处理。
首先要要判断test是否为空:
typeof test!='undefined'
如果为空,则不需进行处理;不为空,继续判断是不是方法:
testinstanceof Function)
最后代码如下:
if(typeof test!='undefined'&test instanceof Function)
test ();
}