this.dragCommand = document.createElement("div");this.dragCommand = {
innerHTML : "<img src='images/pan1.gif'></img>",
onclick : function(){},
className : "commandBtn",
};出错信息:
Error: uncaught exception: [Exception... "Node cannot be inserted at the specified point in the hierarchy" code: "3" nsresult: "0x80530003 (NS_ERROR_DOM_HIERARCHY_REQUEST_ERR)" location: "http://127.0.0.1:8000/javascripts/MapHelper.js Line: 184"]下面是184行代码:
this.commandPane.appendChild(this.dragCommand);
innerHTML : "<img src='images/pan1.gif'></img>",
onclick : function(){},
className : "commandBtn",
};出错信息:
Error: uncaught exception: [Exception... "Node cannot be inserted at the specified point in the hierarchy" code: "3" nsresult: "0x80530003 (NS_ERROR_DOM_HIERARCHY_REQUEST_ERR)" location: "http://127.0.0.1:8000/javascripts/MapHelper.js Line: 184"]下面是184行代码:
this.commandPane.appendChild(this.dragCommand);
innerHTML : " <img src='images/pan1.gif'> </img> ",
onclick : function(){},
className : "commandBtn",
}; this.dragCommand
2个变量名是一样的?
后面是想给这个DIV赋值,不知道这样写对不?
innerHTML : " <img src='images/pan1.gif'> </img> ",
onclick : function(){},
className : "commandBtn",
}; 你把this.dragCommand这个DOM节点对象变成了另外一个普通自定义对象然后你又
this.commandPane.appendChild(this.dragCommand);因为this.dragCommand类型被你改变了,所以提示Node cannot be inserted错误=========================================
这么写
this.dragCommand = document.createElement("div");this.dragCommand.onclick=function(){};
this.dragCommand.className='commandBtn';
this.dragCommand.innerHTML='<img src="images/pan1.gif"> </img>';
拆开写的意思是给this.dragCommand的属性赋值你那写法是给this.dragCommand赋值,差别比较细微
innerHTML : " <img src='images/pan1.gif'> </img>";
onclick : function(){};
className : "commandBtn";
};this.commandPane.appendChild(this.dragCommand);