javascript - Display an svg image on Google Chrome -


i encounter problem when want display svg image library d3.js on google chrome.

below code:

var svg = d3.select("body").append("embed");  svg.attr("src","img/drawing.svg").attr("type","image/svg+xml"); 

this code works on firefox, not on google chrome (same problem if use object instead of embed).

but if add style svg picture : attr("style", "display:block"), picture displays on google chrome.

...can explain me happens? because it's pretty ugly display image that.

according w3schools, embed tag "deprecated in html4 , xhtml (but allowed in html5)". should use object tag. following snippet works in chrome:

var svg = d3.select("body").append("object");  svg.attr("data", "http://upload.wikimedia.org/wikipedia/commons/6/6b/bitmap_vs_svg.svg")    .attr("type","image/svg+xml"); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -