我的任务是为 IE10 更新一些 Javascript。我无休止地寻找解决方案,但我似乎无法找到一个解决方案。我坚持的一段代码是:
var svgns = "http://www.w3.org/2000/svg";
this.svgDoc = document.getElementById("SVGDoc").getSVGDocument();
this.grp = this.svgDoc.createElementNS(svgns, "g");
this.grp.setAttribute("id", this.id);
if (this.parent)
this.svgDoc.getElementById(this.parent.id).appendChild(this.grp);
else
this.svgDoc.getDocumentElement.appendChild(this.grp);
最后一行是它失败的地方,给了我错误Unable to get property appendChild
of undefined or null reference。我似乎无法弄清楚为什么它是一个空引用,因为它适用于 IE8 及更低版本。