Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Problem using a script to insert a <use> element

1 view
Skip to first unread message

Boris Zbarsky

unread,
Jul 18, 2009, 9:19:16 PM7/18/09
to
Tetra wrote:
> Is it possible to do this? The attached file successfully adds a <rect>
> element, but then fails to add a <use> element with the exact same method.

You're using:

y.setAttribute('xlink:href', '#wtf')

That's wrong. Welcome to XML namespaces!

You need to use setAttributeNS with the right namespace:
"http://www.w3.org/1999/xlink".

For what it's worth, a tool like DOM Inspector would have told you this.
Firebug, sadly, doesn't seem to expose that information.

-Boris

Jonathan Watt

unread,
Jul 21, 2009, 11:40:26 AM7/21/09
to Tetra
On 7/19/09 3:19 AM, Boris Zbarsky wrote:
> Tetra wrote:
>> Is it possible to do this? The attached file successfully adds a <rect>
>> element, but then fails to add a <use> element with the exact same method.
>
> You're using:
>
> y.setAttribute('xlink:href', '#wtf')
>
> That's wrong. Welcome to XML namespaces!
>
> You need to use setAttributeNS with the right namespace:
> "http://www.w3.org/1999/xlink".

You may also find this doc useful:

http://jwatt.org/svg/authoring/#namespace-aware-methods

0 new messages