javascript not working in embed svg file
<p>I just start learning SVG. got this example code from <a href="http://www.carto.net/papers/svg/manipulating_svg_with_dom_ecmascript/" rel="nofollow">Manipulating SVG Documents Using ECMAScript (Javascript) and the DOM</a>. I change it a little:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;body&gt;
&lt;svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="300" height="300"&gt;
  &lt;script type="text/ecmascript"&gt;
  &lt;![CDATA[
    function changeRectColor(evt) {
      var red = Math.round(Math.random() * 255);
      evt.target.setAttributeNS(null,"fill","rgb("+ red +","+ red+","+red+")");
    }
  ]]&gt;
  &lt;/script&gt;
  &lt;g id="firstGroup"&gt;
    &lt;rect id="myBlueRect" width="100" height="50" x="40" y="20" fill="blue" onclick="changeRectColor(evt)"/&gt;
    &lt;text x="40" y="100"&gt;Click on rectangle to change it's color.&lt;/text&gt;
  &lt;/g&gt;
&lt;/svg&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>It works just fine. I move to separated SVG file, then js code stop working:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;body&gt;
&lt;object type="image/svg+xml" data="exampl3a.svg" /&gt;   
  &lt;script type="text/ecmascript"&gt;
  &lt;![CDATA[
    function changeRectColor(evt) {
      var red = Math.round(Math.random() * 255);
      evt.target.setAttributeNS(null,"fill","rgb("+ red +","+ red+","+red+")");
    }
  ]]&gt;
  &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>SVG file: exampl3a.svg</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
&lt;!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"&gt;
&lt;svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="300" height="300"&gt;
  &lt;g id="firstGroup"&gt;
    &lt;rect id="myBlueRect" width="100" height="50" x="40" y="20" fill="blue" onclick="changeRectColor(evt)"/&gt;
    &lt;text x="40" y="100"&gt;Click on rectangle to change it's color.&lt;/text&gt;
  &lt;/g&gt;
&lt;/svg&gt;
</code></pre>

<p>what should I do?</p>

<p>Thanks
Wes</p>