« Return to Thread: Unhandled events with script type text/javascript?

Unhandled events with script type text/javascript?

by Cyannick :: Rate this Message:

Reply to Author | View in Thread

Hello,

I was doing some simple test to see what Batik could do, and yesterday afternoon I was stuck with unhandled onclick event. My svg worked fine with Firefox, but not with Batik Squiggle.

The svg file :
[code]
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   width="200px"
   height="60px">

<script type="text/javascript">

<![CDATA[

function clickme(evt)
{
   alert('clicked');
}

]]>

</script>
  <defs
     id="defs1351" />
  <g
     id="layer1">
    <rect
       style="fill:#0000ff;fill-opacity:1.0000000"
       id="rect1357"
       width="75.000000"
       height="25.000000"
       x="51.666668"
       y="19.166666"
       onclick="clickme(evt)"
       />
  </g>
</svg>
[/code]

When clicking on the rectangle, this error happened :
SVG Error:
ReferenceError: "clickme" is not defined. (Event attribute file:/......./BasicRectClick.svg:35 onclick#1)


This morning I tried changing script type to text/ecmascript with the type attribute. And suddenly it works !


Note that I had previously tested with text/javascript an onload event with a function that sleeped for a few seconds and then changed the rectangle color. This worked fine so I concluded that text/javascript was well supported.

 « Return to Thread: Unhandled events with script type text/javascript?