源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

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

  • 时间:2021-06-27 18:29 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:使用typeof判断function是否存在于上下文
在窗口加载时,使用typeof判断function是否存在于上下文
<script type="text/javascript"> 
window.onload = function(){ 
try{ 
if(test && typeof(test) == "function"){ 
test(); 
} 
}catch(e){ 
alert("方法不存在"); 
} 
} 
function test(){ 
alert("我是test()方法"); 
} 
</script>
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部