node.setAttribute导致INVALID_CHARACTER_ERR
|
我在函数中有以下代码:
this.HtmlRef = document.createElement( \"canvas\" );
if (!this.HtmlRef)
{
return false;
}
this.HtmlRef.appendChild( document.createTextNode( \"Your browser doesn\'t support dynamic graphic drawings (Canvas)!\" ) );
var Width = document.createAttribute( \"width\" );
var Height = document.createAttribute( \"height\" );
Width.nodeValue = 0;
Height.nodeValue = 0;
this.HtmlRef.setAttribute(Width); /* error */
this.HtmlRef.setAttribute(Height); /* error */
我也曾尝试更改Width和Height的名称,但没有成功!
整个错误消息:
未捕获的错误:INVALID_CHARACTER_ERR:DOM异常5
谢谢。
解决方案是使用setAttributeNode而不是setAttribute
没有找到相关结果
已邀请:
1 个回复
陈獭