hi heiko
you are absolutly right. one has to use currentTarget, not target. but
for the firstChild problem, as long as there are no spaces, u can
securely use it.
as in my structure there is no space, it will work. and i dont think
that a more generic function is a good idea if you just want to explain
a concept.
i just try to keep it simple.
regards
holger
Heiko Niemann wrote:
>
> Hi,
>
> Holger Will wrote:
> > why dont you go:
> >
> > <g id="groupMyId">
> > <g onclick="myfunction(evt)"><use xlink:href="#myref" /></g>
> > <rect ... />
> > </g>
> >
> >
> > so in myfunction,
> > evt.target.firstChild is the useElement, and evt.target.parentNode
> is
> > the outer group.
> >
>
> I think you have to use evt.currentTarget:
> In ASV3 evt.target will still return the use element, so
> evt.target.firstChild throws an error whereas evt.target.parentNode
> should return the nested g element.
>
> Also: AFAIK firstChild will just work if there is no whitespace
> otherwise firstChild will be a textnode. so you would have to say
> firstChild.nextSibling - so actually you have to check all this if
> you want to access elements via scripting
>
>
> <g id="grpElem" onclick="myfunction(evt)">
> <use id="useElem" xlink:href="#myref" />
> <rect id="rectElem".. />
> </g>
>
> function myfunction(e)
> {
> var target = e.target;
> if(e.target.correspondingUseElement) target =
> e.target.correspondingUseElement;
>
> alert(target.getAttributeNS(null,'id'); // returns 'useElem'
> or 'rectElem' - whereever you clicked
> alert(e.currentTarget.getAttributeNS(null,'id'); // returns 'grpElem'
> }
>
>
> Regards-
> -Heiko
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/1U_rlB/TM
--------------------------------------------------------------------~->
-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my membership"
----
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/