getElementById(...)为空或不是对象
来源:互联网 发布:最好用安卓日历软件 编辑:程序博客网 时间:2024/04/29 17:35
“getElementById(...)为空或不是对象”产生的原因可能有很多种,在此我只列出我在实际开发中产生这种错误的原因以及解决方法。
问题再现:
在页面中添加了一个按钮,<input type="button" runat="server" id="btnGet" value="Get" style="display:none"/>
在js中希望通过document.getElementById(“btnGet”)来找到这个节点,结果出现了getElementById(…)为空或不是对象的错误。
问题产生的原因:
Visual Studio编译时将控件的id改成了“ctl00_PageBody_btnGet”,具体原因我也不是很清楚,还有待研究。
解决方法:
运行程序之后,在浏览器中查看哪行代码出现了问题,然后查看源文件,找到出问题的代码,查看在源代码中控件的id,然后将源代码中的控件id替换掉程序中的id,即用document.getElementById(“ctl00_PageBody_btnGet”)替换掉document.getElementById(“btnGet”),问题得到解决。
- document.getElementById(...)' 为空或不是对象
- getElementById(...)为空或不是对象
- document.getElementById为空或不是对象的解决方法
- document.getElementById为空或不是对象的解决方法
- document.getElementById 为空或不是对象 解决方法
- document.getElementById为空或不是对象的解决方法
- document.getElementById为空或不是对象的解决方法
- document.getElementById为空或不是对象的解决方法
- JavaScript中getElementById()为空或不是对象
- JS中“null'document.getElementById为空或不是对象” 的解决办法
- ASP.NET 创建母版页导致js出现“ 'document.getElementById(...)' 为空或不是对象”错误
- JS中“null'document.getElementById为空或不是对象” 的解决办法
- 创建母版页导致js出现“ 'document.getElementById(...)' 为空或不是对象”错误
- 求 window.parent.document.getElementById(...)为空或不是对象的解决办法。
- document.getElementById(" ") 为空或不为对象
- ASP.NET 2.0 创建母版页导致js出现“ 'document.getElementById(...)' 为空或不是对象”错误
- window.external为空或不是对象
- undefined为空或不是对象
- (十四)中央首长来访 - 1
- December 23th Wednesday 2009
- Extjs刷新Grid的方法
- struts2 自动验证框架
- SCJP试题三
- getElementById(...)为空或不是对象
- SCJP试题四
- Java基础
- 测试驱动开发
- PowerDesigner(CDM—PDM—SQL脚本的转换流程) 随笔
- SCJP试题五
- java keywords and language tutorial
- Advanced Serial Programming(翻译)
- showModalDialog和showModelessDialog