Unhandled events with script type text/javascript?

View: New views
3 Messages — Rating Filter:   Alert me  

Unhandled events with script type text/javascript?

by Cyannick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.

Re: Unhandled events with script type text/javascript?

by thomas.deweese :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Cyannick,

Cyannick <yannick.chong@...> wrote on 07/02/2009 05:36:23 AM:

> <script type="text/javascript">

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

    I don't know the current status but text/ecmascript used
to be the only supported mimetype for ecmascript scripts.
But the current (SVN at least) version of Batik now
supports:
        "application/ecmascript",
        "application/javascript",
        "text/ecmascript",
        "text/javascript",

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

   Perhaps you switched versions of Batik?

Re: Unhandled events with script type text/javascript?

by Cyannick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


thomas.deweese wrote:
Hi Cyannick,

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

   Perhaps you switched versions of Batik?
I'm new to using Batik, so I use only latest official release batik 1.7 for JRE 1.4+

Tests were done with :
jdk 1.5.0_08
Eclipse 3.4.1
Linux Suze 10.2