您的位置:首页 > Web前端 > HTML

在使用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>

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐