在使用renderTo中遇到的Uncaught TypeError: Cannot read property 'insertAdjacentHTML' of null
2013-07-17 09:18
1061 查看
作为一个ExtJs的初学者,我会遇到很多错误,刚刚学习ExtJs我是一点没有接触过,不过感觉这个东西学着还是很有意思的
Uncaught TypeError: Cannot read property 'insertAdjacentHTML' of null
这个错误时我写进度条时候出现的错误,这个问题我研究了一天后来找到我学习那本书配的源码才找到错误,引起这个问题
的原因很多,不过我感觉我这个错误对于初学者的我来说确实很难,不过对于学过JavaScript的人来说太不应该了,我在使用
renderTo没有在<body>标签内加div,renderTo是要指到一个容器中,希望我这个文章可以帮助和我一样初学者遇到的问题
<html>
<head>
<title>updateText</title>
<link href="D:ext/resources/css/ext-all.css" rel="stylesheet" type="text/css"/>
<STYLE TYPE="text/css">
.newIcon { background-image: url(image/new.gif) !important; }
.openIcon { background-image: url(image/open.gif) !important; }
.saveIcon { background-image: url(image/save.gif) !important; }
</STYLE>
<script src="D:ext/bootstrap.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
var toolbar = new Ext.toolbar.Toolbar({//创建工具栏
renderTo:'toolbar',
width:300
});
toolbar.add([//向工具栏中添加按钮
{
text:'新建',//按钮上显示的文字
handler:onButtonClick,//点击按钮的处理函数
iconCls:'newIcon'//在按钮上显示的图标
},
{text:'打开',handler:onButtonClick,iconCls:'openIcon'},
{text:'保存',handler:onButtonClick,iconCls:'saveIcon'}
]);
function onButtonClick(btn){//点击按钮时调用的处理函数
alert(btn.text);//取得按钮上的文字
}
});
</script>
</head>
<body>
<div id='toolbar'></div>
</body>
</html>
Uncaught TypeError: Cannot read property 'insertAdjacentHTML' of null
这个错误时我写进度条时候出现的错误,这个问题我研究了一天后来找到我学习那本书配的源码才找到错误,引起这个问题
的原因很多,不过我感觉我这个错误对于初学者的我来说确实很难,不过对于学过JavaScript的人来说太不应该了,我在使用
renderTo没有在<body>标签内加div,renderTo是要指到一个容器中,希望我这个文章可以帮助和我一样初学者遇到的问题
<html>
<head>
<title>updateText</title>
<link href="D:ext/resources/css/ext-all.css" rel="stylesheet" type="text/css"/>
<STYLE TYPE="text/css">
.newIcon { background-image: url(image/new.gif) !important; }
.openIcon { background-image: url(image/open.gif) !important; }
.saveIcon { background-image: url(image/save.gif) !important; }
</STYLE>
<script src="D:ext/bootstrap.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
var toolbar = new Ext.toolbar.Toolbar({//创建工具栏
renderTo:'toolbar',
width:300
});
toolbar.add([//向工具栏中添加按钮
{
text:'新建',//按钮上显示的文字
handler:onButtonClick,//点击按钮的处理函数
iconCls:'newIcon'//在按钮上显示的图标
},
{text:'打开',handler:onButtonClick,iconCls:'openIcon'},
{text:'保存',handler:onButtonClick,iconCls:'saveIcon'}
]);
function onButtonClick(btn){//点击按钮时调用的处理函数
alert(btn.text);//取得按钮上的文字
}
});
</script>
</head>
<body>
<div id='toolbar'></div>
</body>
</html>
相关文章推荐
- 在开发Ext 项目中如果遇到 Uncaught TypeError: Cannot read property 'insertAdjacentHTML' of null
- 表单提交Erro: formSubmit.html:** Uncaught TypeError: Cannot set property 'action' of null解决
- js事件处理程序 Uncaught TypeError: Cannot read property 'addEventListener' of null
- 安卓Webview 加载网页 Uncaught TypeError: Cannot read property 'getItem' of null",
- canvas出现Uncaught TypeError: Cannot read property 'getContext' of null 错误
- Uncaught TypeError: Cannot read property 'value' of null
- js提示Uncaught TypeError: Cannot read property 'options' of null
- 关于"Uncaught TypeError: Cannot read property 'time' of null"的处理
- discuz 出现了Uncaught TypeError: Cannot read property 'appendChild' of null
- Uncaught TypeError: Cannot read property 'value' of null
- Uncaught TypeError: Cannot read property 'width' of null
- Uncaught TypeError: Cannot set property 'innerHTML' of null
- Uncaught TypeError: Cannot read property 'length' of null
- 使用form的方法(例如:reset,clear等)报错Uncaught TypeError: Cannot read property 'tip' of undefined(…)的原因
- Uncaught TypeError: Cannot read property of 'name' null
- 关于js Uncaught TypeError: Cannot read property 'style' of null 问题
- Uncaught TypeError: Cannot read property 'prototype' of null using Openerp 7.0
- Uncaught TypeError: Cannot read property 'offsetTop' of null
- Uncaught TypeError: Cannot read property 'hasOwnProperty' of null
- Uncaught TypeError: Cannot set property 'innerHTML' of null