W3C home > Mailing lists > Public > www-svg@w3.org > October 2000

does document.getElementId("MyElementId") work?

From: Wu Ping <wupingzj@yahoo.com>
Date: Sun, 1 Oct 2000 13:44:20 -0700 (PDT)
Message-ID: <20001001204420.27562.qmail@web310.mail.yahoo.com>
To: www-svg@w3.org
Dear sir,

I try to use the following code to get the reference
of an element in a svg file, but always get the null
result. Could you give me a tip?

<svg width="100" height="100">
  <defs><script><![CDATA[
    function MouseClickHandler() {
      var obj;
        obj = document.getElementById('MyElement');
        if (obj == null)
          alert("Obj is a null!");
        else
          obj.setAttribute('r', '20'); 
        }
  ]]></script>
  </defs>
  <circle id="MyElement" cx="50" cy="50" 
onclick="MouseClickHandler()" r="10"/>
</svg>

I run it with IE5 and adobe svg viewer.

Thank you in advance!

W P

__________________________________________________
Do You Yahoo!?
Yahoo! Photos - 35mm Quality Prints, Now Get 15 Free!
http://photos.yahoo.com/
Received on Sunday, 1 October 2000 16:44:52 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:19 GMT