使用typeof判断function是否存在于上下文

时间:2014-08-14    点击:99   

在窗口加载时,使用typeof判断function是否存在于上下文

<script type="text/javascript"> 
window.onload = function(){ 
try{ 
if(test && typeof(test) == "function"){ 
test(); 
} 
}catch(e){ 
alert("方法不存在"); 
} 
} 
function test(){ 
alert("我是test()方法"); 
} 
</script>
javascript中实现兼容JAVA的hashCode算法代码分享
javascript实现锁定网页、密码解锁效果(类似系统屏幕保护效果)
javascript中的__defineGetter__和__defineSetter__介绍
js 判断图片是否加载完以及实现图片的预下载
js创建表单元素并使用submit进行提交
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved