javascript - svg image is added to DOM, but isn't *visible* unless touched in Firebug -


this question has answer here:

i'm trying add feature webtoy built. uses raw javascript , svg. app has bunch of functionality , on year old , lives @ http://stereosketcher.com. new feature supposed add svg <image> <g> when drag image file onto special spot on screen file system. have dragging , parsing , appending done, image isn't appearing. isn't isn't in markup, it in markup, it's can't see image.

i suspect kind of layering or opacity issue or something, except there 2 weird tricks can make image appear:

  • just copy whole <image> element (xlink:href , all) else's svg editor (like 'try it' editor on @ w3schools)
  • use firebug manually edit markup , touch last few characters of <image> inserting space or carriage-return before "/>" closing tag (removing new character not make image disappear again)

the function add document looks this:

function applyimagetofaces(data) {     var image = document.createelementns("http://www.w3.org/2000/svg", "image");     image.setattribute("width","800");     image.setattribute("height","800");     image.setattribute("xlink:href",data);      shapegroup.appendchild(image); } 

does know kind of behavior is?

edit: when replace 'data' plain link this:

<image width="800" height="800" xlink:href="http://thumbs.ebaystatic.com/d/l225/m/m-eultq6awfeafdhxz9cuja.jpg"/> 

it behaves in same way....

welp. found answer: https://stackoverflow.com/a/26634735/2427417

i had tried before had left out "http://" namespace because copying comment on answer: https://stackoverflow.com/a/12423019/2427417


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -