Cannot set property ‘innerHTML’ of null 错误原因
2014-05-20 11:32
627 查看
Cannot set property ‘innerHTML’ of null 错误原因当出现以下错误:”……is not defined”、”Uncaught TypeError:Cannot set property ‘innerHTML’ of null”、”document.getElementById(“Clock”)is null” 时请注意! 很有可能是js文件中调用了html中的某个节点,并且js在这个调用的对象之前加载了。如果js放在头部时,此时浏览器渲染未进入dom节点,因为提示为空,或者找不到。所以把js代码放到最后或调用的对象后面就行了。 补充:正确的写法应该是在请用对象之前作个判断。 if(document.getElementById(“id”)){dosomething}//备注:没法转载,原文地址http://www.gezidao.com/blog/cannot-set-property-innerhtml-of-null-%E9%94%99%E8%AF%AF%E5%8E%9F%E5%9B%A0/
相关文章推荐
- Cannot set property ‘innerHTML’ of null 错误原因
- 关于React “Cannot read property 'setState' of null” 的错误
- Uncaught TypeError: Cannot set property ' ' of null 错误解决
- ueditor 实例化 Cannot set property 'innerHTML' of null 完美解决方案
- 关于React “Cannot read property 'setState' of null” 的错误
- 关于JS出现的Cannot read property 'XXX' of null错误
- cannot read property 'nodeName' of null 的原因
- JS点击事件——Uncaught TypeError: Cannot set property 'onclick' of null
- canvas出现Uncaught TypeError: Cannot read property 'getContext' of null 错误
- ASP.NET MVC运行出现Uncaught TypeError: Cannot set property __MVC_FormValidation of null的解决方法
- Cannot set property 'onclick' of null的问题
- Uncaught TypeError: Cannot set property 'innerHTML' of null
- 表单提交Erro: formSubmit.html:** Uncaught TypeError: Cannot set property 'action' of null解决
- 学习笔记3--Cannot set property 'onclick' of null的问题
- 泪的教训!"Uncaught TypeError: Cannot set property 'value' of null"
- Uncaught TypeError: Cannot set property 'display' of undefined错误
- 浏览器出现Cannot set property 'onclick' of null的问题
- UEditor的setContent的时候报错,报错代码如下 Uncaught TypeError: Cannot set property 'innerHTML' of undefined 错
- Cannot set property 'innerHTML' of null"
- Uncaught TypeError: Cannot set property 'innerHTML' of null