使用typeof判断function是否存在于上下文_Javascript教程-查字典教程网
使用typeof判断function是否存在于上下文
使用typeof判断function是否存在于上下文
发布时间:2016-12-30 来源:查字典编辑
摘要:在窗口加载时,使用typeof判断function是否存在于上下文window.onload=function(){try{if(test&...

在窗口加载时,使用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教程学习
    热门Javascript教程学习
    编程开发子分类