R
Raoul.Kamadjeu
I want to dynamically create link to a text on an svg document. I've
implemented this piece of code. Any idea why this doen't link to
google.com?
<svg>
<script onload="init(evt)">
function init(evt) {
var SVGDoc = evt.getTarget().getOwnerDocument();
var text_elem = SVGDoc.getElementById("text_elem");
var a_elem = SVGDoc.createElement("a");
var text_node = SVGDoc.createTextNode("This is a link");
a_elem.setAttributeNS
("http://www.w3.org/2000/xlink","xlink:href","http://www.google.com");
a_elem.setAttribute("id", "link");
a_elem.setAttribute("target", "_blank");
a_elem.appendChild(text_node);
text_elem.appendChild(a_elem);
}
</script>
<text id="text_elem" x="0" y="1em"> </text>
</svg>
Thanks
implemented this piece of code. Any idea why this doen't link to
google.com?
<svg>
<script onload="init(evt)">
function init(evt) {
var SVGDoc = evt.getTarget().getOwnerDocument();
var text_elem = SVGDoc.getElementById("text_elem");
var a_elem = SVGDoc.createElement("a");
var text_node = SVGDoc.createTextNode("This is a link");
a_elem.setAttributeNS
("http://www.w3.org/2000/xlink","xlink:href","http://www.google.com");
a_elem.setAttribute("id", "link");
a_elem.setAttribute("target", "_blank");
a_elem.appendChild(text_node);
text_elem.appendChild(a_elem);
}
</script>
<text id="text_elem" x="0" y="1em"> </text>
</svg>
Thanks