| 标题 | 使用typeof判断function是否存在于上下文 |
| 内容 | 在窗口加载时,使用typeof判断function是否存在于上下文 view sourceprint? 01 <script type="text/javascript"> 02 window.onload = function(){ 03 try{ 04 if(test && typeof(test) == "function"){ 05 test(); 06 } 07 }catch(e){ 08 alert("方法不存在"); 09 } 10 } 11 function test(){ 12 alert("我是test()方法"); 13 } 14 </script> |
| 随便看 |
|
在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。