使用typeof判断function是否存在于上下文
更新时间:2014年08月14日 17:38:17 投稿:whsnow
这篇文章主要介绍了使用typeof判断function是否存在于上下文,在窗口加载时,使用typeof进行判断,需要的朋友可以参考下
在窗口加载时,使用typeof判断function是否存在于上下文
<script type="text/javascript">
window.onload = function(){
try{
if(test && typeof(test) == "function"){
test();
}
}catch(e){
alert("方法不存在");
}
}
function test(){
alert("我是test()方法");
}
</script>
相关文章
Sample script that deletes a SQL Server database
Sample script that deletes a SQL Server database...2007-06-06


最新评论