I'm working on a JavaScript project to display SVG elements, but I'm encountering an issue with the "image" element. For some reason, when I create the image element dynamically, it doesn't appear in the browser. However, if I manually copy the code and paste it into another document, the image shows up without any problems.
Upon inspecting the image using Firebug's inspector tool, I can see that the object is being created, but the actual image is not being displayed.
To create the object, I am using methods like appendChild()
, setAttribute()
, and setAttributeNS()
.
Here is the code that is being generated:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="100%" width="100%" >
<image width="50" height="50" xlink:href="logo.png" y="20" x="20" id="d"></image>
</svg>
I'm stumped as to what could be causing this issue. Any ideas?