Uncaught TypeError: Cannot set property 'innerHTML' of null

学习Chrome插件时,要在弹出页面中显示当前时间,结果怎样也显示不出来

看了 http://www.cnblogs.com/mfryf/p/3701801.html 这篇文章后感悟颇深

通过调试发现在js中的一段代码没有执行到,报以下错误

  Uncaught TypeError: Cannot set property ‘innerHTML‘ of null 

  然后查询该错误原因,结果是因为js引用放在了页面的头部,在修改 innerHTML 属性时找不到该属性,因为需要修改一个html标签中的内容,因此需要html加载并解析完成之后才能找到对应id的标签,在 head 处引用 js 导致 js 找不到对应 id ,当将 js 引用放在 body 尾部之后就可以正常显示了。

学习了这么久的编程从来没有好好学习过调试程序的方法,一直都在用 console.log() 、syso()、alert(),真得要好好学习一下程序调试的方法了,太受用了

Uncaught TypeError: Cannot set property 'innerHTML' of null

时间: 2024-08-03 14:12:50

Uncaught TypeError: Cannot set property 'innerHTML' of null的相关文章

Uncaught TypeError: Cannot read property 'ownerDocument' of null

/********************************************************************* * Uncaught TypeError: Cannot read property 'ownerDocument' of null * 说明: * 尝试将SVG文件内容通过JS Ajax加载,然后动态插入div中,报这个错误, * 解决办法,直接将svg后缀改成html,就可以了. * * 2017-8-25 深圳 龙华樟坑村 曾剑锋 *********

vue报错 Uncaught TypeError: Cannot read property ‘children ’ of null

Uncaught TypeError: Cannot read property 'children ' of null ratings未渲染完毕,就跳走goods了,取消默认跳转,即可

Three.js three.js Uncaught TypeError: Cannot read property 'getExtension' of null

在调试Three.js执行加载幕布的时候,突然爆出这个错误three.js Uncaught TypeError: Cannot read property 'getExtension' of null,查询了半天也没找到结果 最后突然想到是不是浏览器的设置问题,检查了一下WebGL,果然重新安装浏览器之后没有开启,正常开启之后,显示正常 留痕MARK一下 PS:可以直接在百度上搜索浏览器的WebGL的开启方式 :) Three.js three.js Uncaught TypeError: C

Uncaught TypeError: Cannot read property 'appendChild' of null

出现了这个是因为把js放在了head中,而我获取的是在body中的东西.html整体上是至上而下的流程.因此需要将js从head中放置到body中就可以了. Uncaught TypeError: Cannot read property 'appendChild' of null 原文地址:https://www.cnblogs.com/logsapling/p/9995904.html

Uncaught TypeError: Cannot read property ‘style‘

js在浏览器报出如下错误(chrome中):Uncaught TypeError: Cannot read property 'style' of null 浏览器如果报出如下错误(chrome中):Uncaught TypeError: Cannot read property 'style' of null  请问这错误具体是什么意思?(您需要掌握JS常见错误的处理和常见英文报错的意思) 调用style属性的object是空的,一般是元素获取出错造成的 比如你想用 document.getE

百度ueditor 实例化 Cannot set property 'innerHTML' of null 完美解决方案

此时此刻,我正在用博客园推荐的TinyMCE编辑器写这个博客,突然想起最近在项目中使用百度ueditor编辑器中的一些经历.所以记录在此,与大家分享. 不得不说,百度ueditor是一款很好的在线编辑器,为开发者提供了诸多便利,你甚至可以用它来把word文档的内容按照一定的格式转换成html代码,然后再放进自己的项目中. 1.我们的项目中,用户在注册时有可能需要查看用户协议和隐私协议,而我们的文案是将这两个协议的内容放在word文档中,作为苦逼的开发人员,你需要把这些文字展示在html页面上,并

reactjs Uncaught TypeError: Cannot read property 'location' of undefined

reactjs Uncaught TypeError: Cannot read property 'location' of undefined reactjs 路由配置 怎么跳转 不成功 国内搜索引擎 找半天找不到 有用 资料 于是 goolge package.json 里面配置: "react-router": "^3.0.0"  改为3.x 就可以了 , 改完 执行 npm install 原文参考: https://github.com/acdlite/r

easyui Datagrid查询报错Uncaught TypeError:Cannot read property 'length' of undefined

1.问题描述 easyui中datagrid执行loadData方法出现如下异常:Cannot read property 'length' of undefined 2.一开始怀疑是js或者页面的问题,然后从早上干到下午,网上各种方法用尽了就是不行! 最后发现规律了: 使用mybatis从数据库查询返回的List不报错,但是自己new的ArrayList总是报错! 后来发现原来mybatis返回的不是ArrayList!而是PageList! 3.解决问题 PageList中有个参数Pagin

Uncaught TypeError: Cannot set property 'f7View' of undefined 错误原因

// 添加视图var mainView = myApp.addView('.view-main', { // 因为我们要用动态的导航栏,我们需要使它的这一观点: dynamicNavbar: true});// 添加视图var mainView4 = myApp.addView('.view-main4', { // 因为我们要用动态的导航栏,我们需要使它的这一观点: dynamicNavbar: true}); 错误原因,多了一个添加视图,删除一个就好 Uncaught TypeError: