Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Any idea why this piece of js code in svg doesn't link to target?

Reply
Thread Tools

Any idea why this piece of js code in svg doesn't link to target?

 
 
Raoul.Kamadjeu@gmail.com
Guest
Posts: n/a
 
      06-13-2006
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

 
Reply With Quote
 
 
 
 
Kam-Hung Soh
Guest
Posts: n/a
 
      06-13-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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


Try:

1. http://www.w3.org/1999/xlink.
2. Replace "xlink:href" with just "href". When using setAttributeNS(),
the first argument is the namespace.

Works on ASV3, but I don't know if it'd work on other browsers.

Regards,

--
Kam-Hung Soh
http://kamhungsoh.blogspot.com - It Mostly Works
http://members.optusnet.com.au/khsoh - Software That Mostly Works

 
Reply With Quote
 
 
 
 
Raoul.Kamadjeu@gmail.com
Guest
Posts: n/a
 
      06-14-2006

Kam-Hung Soh wrote:
> (E-Mail Removed) wrote:
> > 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

>
> Try:
>
> 1. http://www.w3.org/1999/xlink.
> 2. Replace "xlink:href" with just "href". When using setAttributeNS(),
> the first argument is the namespace.
>
> Works on ASV3, but I don't know if it'd work on other browsers.
>
> Regards,
>
> --
> Kam-Hung Soh
> http://kamhungsoh.blogspot.com - It Mostly Works
> http://members.optusnet.com.au/khsoh - Software That Mostly Works


Nope, it doesn't

 
Reply With Quote
 
Raoul.Kamadjeu@gmail.com
Guest
Posts: n/a
 
      06-14-2006

Kam-Hung Soh wrote:
> (E-Mail Removed) wrote:
> > 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

>
> Try:
>
> 1. http://www.w3.org/1999/xlink.
> 2. Replace "xlink:href" with just "href". When using setAttributeNS(),
> the first argument is the namespace.
>
> Works on ASV3, but I don't know if it'd work on other browsers.
>
> Regards,
>
> --
> Kam-Hung Soh
> http://kamhungsoh.blogspot.com - It Mostly Works
> http://members.optusnet.com.au/khsoh - Software That Mostly Works


By the way, cool.. the game

 
Reply With Quote
 
Kam-Hung Soh
Guest
Posts: n/a
 
      06-14-2006
(E-Mail Removed) wrote:

> By the way, cool.. the game


Thanks. Sorry I couldn't solve your problem.

--
Kam-Hung Soh
http://kamhungsoh.blogspot.com - It Mostly Works
http://members.optusnet.com.au/khsoh - Software That Mostly Works

 
Reply With Quote
 
Raoul.Kamadjeu@gmail.com
Guest
Posts: n/a
 
      06-15-2006
No man, you solved my problem, I forgot to replace 2000 by 1999. Thanks
so much.

Kam-Hung Soh wrote:
> (E-Mail Removed) wrote:
>
> > By the way, cool.. the game

>
> Thanks. Sorry I couldn't solve your problem.
>
> --
> Kam-Hung Soh
> http://kamhungsoh.blogspot.com - It Mostly Works
> http://members.optusnet.com.au/khsoh - Software That Mostly Works


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Download a file piece by piece Patrick Plattes Ruby 2 11-30-2006 07:48 PM
[SVG] probleme dessin d'images SVG avec Batik Mardagg Java 0 05-12-2006 02:13 PM
[SVG] problem with SVG image drawing with Batik Library Mardagg Java 0 05-12-2006 02:12 PM
[SVG] using image-tag to integrate SVG in SVG Arne Nordmann XML 0 06-28-2004 01:16 PM



Advertisments