js判断某个方法是否存在

window.onload = function(){
	try{
		if(test && typeof(test) == "function"){
			test();
		}
	}catch(e){
		alert("方法不存在");
	}
}
function test(){
  alert("我是test()方法");
}

  

posted @ 2015-03-05 09:51  雪卜  阅读(4035)  评论(0)    收藏  举报