As it is one of the most popular scripting language and as the SVG specification states that an SVG conforming implementation should support it, the ECMAScript (JavaScript) language is supported in Batik through the Mozilla ECMAScript interpreter called Rhino. Even if it is the only scripting language provided with the Batik standard distribution, other languages such a Python or Tcl can also be supported. All examples in this section will use ECMAScript.
There are two places in an SVG file where you can put scripts.
The first one is in the <script> element where you can put the
definition of your functions or some general code to be executed when the
element will be read.
 |  |  |
 |
<svg width="100" height="100">
<script type="text/ecmascript">
// ECMAScript code to be executed
</script>
<!-- Your SVG elements -->
</svg> |  |
 |  |  |
You can also put script in response to user or document events using attributes on SVG elements. As shown in the previous example, the scripting language must be set on the <script> element. However for event handling the default language type "text/ecmascript" is already set. If you want to change it you can use the contentScriptType attribute on the <svg> element.
In most cases, the event attribute will only call a function defined in a <script> section, however as you can see below it can also contains regular code.
 |  |  |
 |
<svg width="100" height="100">
<rect x="0" y="0" width="10" height="10"
onclick="evt.target.setAttribute('fill', 'blue')"/>
<!-- Your SVG elements -->
</svg> |  |
 |  |  |
For more information on using scripting in SVG you can have a look at: