I started looking at Firefox with native SVG enabled.  The following 
file shows a few ways to modify a text element character data.  You 
click on the text item and it is modified.  Simple.  They don't all 
work in Firefox/SVG.

The programmer in me says just code it the way that works, but I am 
wondering:
1) What is the recommended way to code it that is least apt to break 
in the future?
2) In the cases that don't work, what is broken, Firefox/SVG or my 
code?

--------------------
<?xml version='1.0'?>
<svg xmlns='http://www.w3.org/2000/svg' width="500" height="400" 
onload="init(evt)">
<defs>
<script>
<![CDATA[
var svgDoc;
function init(evt)
{
  svgDoc = evt.target.ownerDocument;
}
function onClick(evt)
{
  var element = evt.target;
  var id = element.getAttribute('id');
  switch (id){
    case 'text1':  // works in Squiggle and ASVG
      element.getFirstChild().setData("hello");
      break;
    case 'text2':  // works in Squiggle and ASVG
      element.getFirstChild().data = "hello";
      break;
    case 'text3':  // works in Squiggle and ASVG
      element.firstChild.setData("hello");
      break;
    case 'text4':  // works in Squiggle, Firefox/SVG and ASVG
      element.firstChild.data = "hello";
      break;
    case 'text5':  // works in Squiggle, Firefox/SVG and ASVG
      element.firstChild.nodeValue = "hello";
      break;
  }
}
]]>
</script>
</defs>
<g onclick="onClick(evt)" fill="green" font-size="18">
  <text id="text1" x="20" y="100" >element.getFirstChild().setData
("hello")</text>
  <text id="text2" x="20" y="150" >element.getFirstChild().data 
= "hello"</text>
  <text id="text3" x="20" y="200">element.firstChild.setData("hello")
</text>
  <text id="text4" x="20" y="250">element.firstChild.data 
= "hello"</text>
  <text id="text5" x="20" y="300">element.firstChild.nodeValue 
= "hello"</text>
</g>
</svg>





-----
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/
 


Reply via email to