2

我的任务是为 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 appendChildof undefined or null reference。我似乎无法弄清楚为什么它是一个空引用,因为它适用于 IE8 及更低版本。

4

1 回答 1

0

getDocumentElement 应该只是documentElement根据这个可以在几乎所有版本的 IE 上工作

于 2013-08-12T09:35:28.830 回答