在窗口加载时,使用typeof判断function是否存在于上下文
<script type="text/javascript"> window.onload = function(){ try{ if(test && typeof(test) == "function"){ test(); } }catch(e){ alert("方法不存在"); } } function test(){ alert("我是test()方法"); } </script>
最后
以上就是认真芝麻最近收集整理的关于使用typeof判断function是否存在于上下文的全部内容,更多相关使用typeof判断function是否存在于上下文内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复