Andre and David: Thanks for your responses. I think my problem has to do with my lack of understanding of the SVG DOM and event handling. Here's my example that I'm wresting with:
A web page 3.html contains 3.svg in an iframe: <html> <head> <title>TestBed</title> </head> <body> <iframe id="map" width="400" height="400" src="3.svg" type="image/svg+xml"></iframe> <textarea id="output" rows="10" cols="40" > </textarea> </body> </html> 3.svg looks like: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <svg width="210pt" height="272pt" viewBox = "-1 -1 209 271" xmlns="http://www.w3.org/2000/svg" > <script type="text/ecmascript"> <![CDATA[ function getSummary(evt) { var element = evt.target; var myid = element.getAttributeNS(null,'id'); var buf = "The ID is " + myid + "."; // textarea in html var foo = top.document.getElementById("output"); foo.value = buf; } ]]> </script> <g id="node1" class="node" onclick="getSummary(evt);" > <title>node1</title> <polygon id="poly" fill="#ff0000" stroke="#ff0000" points="59,4 5,4 5,40 59,40 59,4" /> <text id="text" text-anchor="middle" font-family="arial" font-size="8px;" x="32" y="23"> Node 1 </text> </g> </svg> So what happens is that when I click on the polygon I get the output "The ID is poly." When I click on the text node 1, I get "The ID is text." Makes sense, but I what I really want is the id of the surrounding group (id="node1") to be returned. Is there a way to do that? BTW, I'm using Firefox 1.5rc2 without a plugin if that makes a difference. Thanks, Todd --- In svg-developers@yahoogroups.com, david dailey <[EMAIL PROTECTED]> wrote: > > I think andré is correct. > > But when the event handler is a group, one might > expect the group id to be returned. Instead (at > least in dragging things around) I had to pass the group id as a parameter. > > In > http://srufaculty.sru.edu/david.dailey/svg/drag4.svg > (which works in either IE/ASV3 or Firefox 1.5 gamma?) I did something like > > function trap(evt,id){ > if (arguments.length==1) id=evt.target.id > ... > } > > so that if the second argument didn't exist I > would fill it in as the target of the event. But > in the case of groups I found that whichever > object within the group actually received the > event, its id was returned even though the event > listener was assigned to the group. I suspect > somebody has a better solution, but I may have > been sleeping the last time events and groups > were discussed. In the meantime I contemplated > finding which id was returned then checking to > see if that id has a parent who happens to be a > group, but that made me sleepy again. > > David > > At 12:33 PM 11/11/2005, andréwrote: > >alert(elementdata[evt.target.getAttributeNS(null,'id')]); > > > >andré > > > >brunertodd wrote: > > > Apologies in advance for a stupid question that so far has resisted > > > "googling." > > > > > > I wish to know the "Id" value for a node that has been clicked. for > > > example: > > > > > > <g id="mybox" onclick="printData(evt)"> > > > <polygon points="4,0 0,0 0,4 4,0" /> > > > <g> > > > > > > where the javascript section would look like > > > > > > elementdata["mybox"] = "Long winded description number 1"; > > > elementdata["yourbox"] = "Another description. Yea!"; > > > > > > function printData(evt) { > > > var element = evt.target; > > > var idvalue = ????????? // dom method? > > > alert(elementdata[idvalue]); > > > } > > > > > > I know that element is the object, but I need to tie to some data > > > outside the element's attributes that is indexed by the Id, in this > > > case "mybox". > > > > > > so I want the alert box to display "Long winded description number 1" > > > when the "mybox" svg object is clicked. But I don't know a way to set > > > the idvalue variable to the id of the <g>. > > > > > > Thanks for your help! > > > > > > Todd > > > > > > > > > > > > > > > > > > > > > ----- > > > 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 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >-- > >___________________________________________________________________ > >andre m. winter, > > cartography for internet and multimedia applications > > schiessstand 4/1, a6091 goetzens, tyrol, austria > > tel.: ++43.5234.32732 > > email: <[EMAIL PROTECTED]> > > > ><http://www.vectoreal.com/> SVG consulting and development > ><http://www.carto.net/> online cartography focusing on SVG > ><http://www.carto.at/> print and online touristic map solutions > > > > > > > > > > > >----- > >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 > > > > > > > > > ------------------------ Yahoo! Groups Sponsor --------------------~--> Fair play? Video games influencing politics. Click and talk back! http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/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/