ASV Internal JavaScript Engine
From Svg wiki
The Adobe SVG Viewer v3.0 comes with its own JavaScript engine. This is turned on in browsers that don't support communication between plug-ins and javascript . If you want to turn it on in all browsers, create a SVG tag like this:
<svg xmlns:a3="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/" a3:scriptImplementation="Adobe">
If you also want it to validate, then change your DOCTYPE to declare the appropriate attributes, like this:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-_W3C_DTD SVG 1.0_EN"
"http://www.w3.org/TR/SVG/DTD/svg10.dtd" [
<!ATTLIST svg
a3:scriptImplementation CDATA #IMPLIED
xmlns:a3 CDATA #IMPLIED>
<!ATTLIST script
a3:scriptImplementation CDATA #IMPLIED>
]>
ASV uses the Mozilla (Rhino) JavaScript engine (specifically, SpiderMonkey), as does Batik and Mozilla itself. This means that it can handle JavaScript 1.5 things like getters and setters. For example, try this code in ASV:
function myClass(){
this.a = 9
}
myClass.prototype.__defineGetter__("b", function () {
alert("b get ")
return a
})
myClass.prototype.__defineSetter__("b", function (f) {
alert("b set to " + f)
a = f
})
myInstance = new myClass()
myInstance.b = 89
By default, Adobe SVG Viewer tries to use browser script engine. If it cannot (for any reason), it falls back to its own internal script engine. The attribute ==a3:scriptImplementation== allows one to change this behavior. Possible values are:
| VALUE | EFFECT |
|---|---|
| Adobe | use Adobe SVG Viewer built-in script engine |
| browser | use browser script engine, do nothing if it is not possible |
| Netscape | use Netscape's script engine in browser, do nothing if it is not possible |
| Microsoft | use Microsoft's script engine in IE browser, do nothing if it is not possible |
Different <script> elements can have different values for this attribute (and therefore run in different script engines). However default event listeners (content of onfoo attributes) always run in the script engine that was defined for top-level svg element.
a3:scriptImplementation is a supplemental attribute for the Content Script Type attribute on the <svg> elemenent and type attribute on <script> elements. Placing these attributes on <svg> or <script> elements "resets" a3:scriptImplementation to its default value.
