xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claire Wall" <claz...@hotmail.com>
Subject ECMAScript and SVG question
Date Fri, 07 Mar 2003 14:03:51 GMT
<html><div style='background-color:'><DIV><FONT face="Geneva, Arial, Sans-serif">hi,</FONT></DIV>
<DIV><FONT face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif">I have an SVG image of a dice that,
when clicked, changes the stroke of the dice to yellow and back again.</FONT></DIV>
<DIV><FONT face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif">im trying to get the stroke of a rectangle
to change when i click on it and anything inside it (i.e. the dots of the dice). <BR>The
code i have at the moment is:</FONT></DIV>
<DIV><FONT face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif">&lt;SVG&gt;</FONT></DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif">&lt;script type="text/ecmascript"&gt;</FONT></DIV>
<DIV><FONT face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif">var click = 0;<BR>function hold(evt)<BR>{<BR>&nbsp;if(click%2==0)
evt.target.setAttribute('stroke', 'yellow');<BR>&nbsp;if(click%2!=0) evt.target.setAttribute('stroke',
'#DD1212');<BR>&nbsp;click++;<BR>}</FONT></DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif">&lt;/script&gt;</FONT></DIV>
<DIV><FONT face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif">&lt;g id="dice"&gt;</FONT></DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif"><BR>&lt;rect id="DiceRect"
x="0" y="0" rx="5" ry="5" height="40" width="40" fill="#DD1212"&nbsp; stroke="#DD1212"
stroke-width="2" onclick="hold(evt)"/&gt;</FONT></DIV><FONT face="Geneva,
Arial, Sans-serif">
<DIV><BR>&lt;circle cx="20" cy="20" r="3" style="fill:#FFFFFF; fill-opacity:1;"/&gt;</DIV>
<DIV><BR>&lt;/g&gt;</FONT></DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif">&lt;/SVG&gt;</FONT></DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif"></FONT>&nbsp;</DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif">How could i change the ecmascript
so that if i put the onclick event in the &lt;g&gt; tag like: &lt;g id="dice"
onclick="hold(evt)"&gt;, i could change the colour of the rectangle even if i click on
the dot in the rectangle? </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif">Would it be something like document.????.setAttribute('stroke',
'yellow') or something? I can't figure this out.</FONT></DIV>
<DIV><FONT face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif">So what i'm asking is, how could i
change my code so that if i click on any part of the dice (rect or circle) the stroke of the
rectangle will change?</FONT></DIV>
<DIV><FONT face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif">Thanks<BR>Claire :)</FONT></DIV>
<DIV></DIV></div><br clear=all><hr>Chat with friends online
-  <a href="http://g.msn.com/8HMHENUK/2734">download MSN Messenger </a> today.</html>

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message