Hi,
I have a .svg file with a "line" Element with a link to an new page.
This means that if you click on the line a new page will open.
Here is a part of the code from the .svg file:
<svg version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="530" height="530"
onload="init(evt);"
font-size="12">
<a xlink:href="./relations.and.abstracts/rel-1.html" target="_blank">
<line id="Line1" x1="310" x2="220" y1="310" y2="220" stroke="silver" stroke-width="2"/>
</a>
You see the line element is embedded in a 'a'.
Now I repaint the line in a Javacript file with the DOM:
svgDocument.documentElement.appendChild("lineID");
The line is now on top of the z-index this is what I want but the problem is that the link when you click on the line is disappeared.
Now I tried to get access to the line Object and add a link.
svgDocument.getElementById("lineID").addEventListener("click", getAttributes, false);
This works when i click on the line the function getAttributes() is called.
But when i want to set a link like this nothing happens:
svgDocument.getElementById("lineID").setAttributeNS("http://www.w3.org/1999/xlink/namespace/", "href", "http://www.google.com/");
Has anabody an Idea how to create a link to another page with a DOM Object? I tried all variations of the setAttributeNS() and the setAttribute() Function.
Even I tried to Capsule the line Object in an Anchor Object with a link like in the .svg file.
Does anybody know how to set a link for a DOM Object?