I have an SVG image file and I want to place it on an HTML page as an SVG. Therefore, I still take advantage of the high resolution Zoom in / out.
Here is my code. I put SVG inside, inside SVG.
The code works correctly, but SVG is not displayed in the browser.
1) How can I show this? 2) Is there a way to place SVG as SVG with all its functions (I read some question, but it doesn’t work with me).
var div = document.createElement("div");
div.id="dsvg";
div.class="cdsvg";
div.style.width = "auto";
div.style.height = "210px";
var link='SVGimage.svg';
var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svg.setAttribute("height", 210);
svg.setAttribute("width", 500);
var XLink_NS = 'http://www.w3.org/1999/xlink';
var img = document.createElementNS(svg, 'image');
img.setAttributeNS(null, 'height', '210');
img.setAttributeNS(null, 'width', '500');
img.setAttributeNS(XLink_NS, 'xlink:href', link);
svg.appendChild(img);
var cell3 = row.insertCell(3);
div.appendChild(svg);
cell3.appendChild(div);
This HTML code works, but when I port it to JavaScript, it doesn't ...
<svg id="svgimg" height="60" width="60" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >
UPDATE: I see SVG as img now: I added a library to switch to SVG (because I want to change the color of the lines and the rectangle inside the SVG)
var link='test.svg';
var svgframe = document.createElement('img');
svgframe.id="svgframe";
svgframe.class="svg";
svgframe.setAttribute('src',link );
var SVGs = document.querySelectorAll('.svg');
SVGInjector(SVGs);
, img tag, SVG?? , SVG,