`

Cannot call method 'appendChild' of null

阅读更多
调试过程中出现一个奇怪的错误:Uncaught TypeError: Cannot call method 'appendChild' of null。只有在谷歌浏览器出现这个错误,其他IE系列,FF,Opera都是正常。找了一下原因,js的document.body.appendChild(container);是在 body 之前运行的,这个时候,document.body 不存在,即为 null ,所以 document.body.appendChild 就会报告上面的错误。把SCRIPT 代码包含到 <body></body> 里面就可以正常运行了 
分享到:
评论
1 楼 icuy 2011-05-13  
我刚刚也遇到这个问题了,错误提示是"2Uncaught TypeError: Cannot call method 'addClass' of null",特意通过了万恶的论坛问答考验,发一个感谢贴.

相关推荐

Global site tag (gtag.js) - Google Analytics