我有 IE 10 和 svg 图像。在 svg 中,我将 TEXT 元素与
var newElement = function(name, attr) {
var svgNS = "http://www.w3.org/2000/svg";
var tmp = document.createElementNS(svgNS, name);
for (k in attr) {
if (k === 'style') {
for (s in attr[k]) {
tmp.style[s] = attr[k][s];
}
} else if (k === 'innerHTML') {
console.log('Break 1('+typeof(attr[k])+')'+ attr[k]);
console.log('Break 2: '+tmp.innerHTML);
tmp.innerHTML = attr[k];
console.log('Break 3: '+tmp.innerHTML);
} else {
tmp.setAttributeNS(null, k, attr[k]);
}
}
console.log('Break 4: ');
console.log(tmp);
return tmp;
};
而且我无法在 IE 中看到放置的文本。在 FF 和 Chrome 中它工作正常。 在源代码中我可以看到空文本元素,但文本元素具有属性。
它是来自 IE 控制台的日志:
Break 1(string)Coś tam Marzec: 158
Break 2: undefined
Break 3: Coś tam Marzec: 158
Break 4:
<text id="1135198_point_2_desc" font-size="11" visibility="hidden" text-anchor="middle" x="204.8182" y="209.68"></text>
Firefox 控制台:
Break 1(string)Legenda Pionowa
svg.html (wiersz 50)
Break 2:
svg.html (wiersz 51)
Break 3: Legenda Pionowa
svg.html (wiersz 53)
Break 4:
svg.html (wiersz 59)
<text x="0" y="130" text-anchor="middle" fill="#000000" transform="rotate(-90, 20, 130)">
而在 firefox 中,文本位于 TEXT 元素内
最佳答案
好的,我解决了我的问题。我用了https://code.google.com/p/innersvg/ 我将 innerHTML 替换为 innerSVG
关于javascript - innerHTML 在 IE 10 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28604693/