简体   繁体   English

IE9的foreignObject的替代品

[英]alternative to foreignObject for IE9

i really like foreignObject to show HTML regions over svg, but today i found out that it doesnt work in IE9 (why am i not surprised) ok. 我真的很喜欢foreignObject在svg上显示HTML区域,但今天我发现它在IE9中不起作用(为什么我并不感到惊讶)好。 So i am looking for an alternative that works in IE9, but it seems difficult. 所以我正在寻找一种适用于IE9的替代方案,但似乎很难。 The great thing of using foreignObject to display multiple HTML elements. 使用foreignObject显示多个HTML元素的好处。

My D3.js Force layout graph is working great in chrome and FF , but in IE9 it fail because of foreignObject . 我的D3.js Force布局图在chrome和FF中工作得很好,但是在IE9中它因为foreignObject而失败。 i add many HTML elements in to Div and also more CSS stuff. 我在Div中添加了许多HTML元素,还有更多的CSS内容。 I try to replace foreignObject with other xhtml:div or xhtml:body but it's not working 我尝试用其他xhtml:div或xhtml:body替换foreignObject但它不起作用

here is two Fiddles 这是两个小提琴

Working Fiddle 工作小提琴

need to run on IE9 需要在IE9上运行

Modified Fiddle 改良小提琴

node.append("foreignObject")
    .attr("class", "simpleDiv")
    .attr("width",50)
    .attr("overflow", "visible")
    .attr("height", 50)
    .append("xhtml:div").attr("class", "mainDiv").style("cursor", hoverStyle)
    .html(function (d) {
       var htmlString = "";
       var userImage = "http://t2.gstatic.com/images?q=tbn:ANd9GcT6fN48PEP2-z-JbutdhqfypsYdciYTAZEziHpBJZLAfM6rxqYX";
       htmlString += "<div class='userImage' style='border-color:" + color(d) + "'><image src='" + userImage + "' width='36' height='36'></image></div>";
       htmlString += "<div class='content' style='color:" + color(d) + ";'>" + d.name + "</div>";
       htmlString += "<div style='clear:both;'></div>";
       return htmlString;
     });

you can test original example in IE9 also foreignObject 你可以在IE9中测试原始例子也是foreignObject

I don't think it's possible to make foreignObject work in IE9. 我不认为可以在IE9中使foreignObject工作。 But for your particular task why not just render the user icon and name with <image> and <text> elements? 但是对于您的特定任务,为什么不只是使用<image><text>元素呈现用户图标和名称?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM