• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 15. Scripting SVG > Specifying the Scripting Language

Specifying the Scripting Language

The standard scripting language is, as we have already told you, ECMAScript. So, if you are using only ECMAScript (and we recommend that you do so), you do not need to change anything in your code to use the ECMAScript interpreter. Chances are close to zero that the default scripting language will change within the next few releases of the SVG specification.

If you want to use another scripting language, however, or are uncertain whether all scripting-capable SVG viewers use ECMAScript as their default (according to the SVG spec, they should), you can tell the SVG viewer precisely which language you are planning to use. For that, the contentScriptType attribute of the svg element comes into play. There, you can set the default scripting language for the whole SVG document. You do not have to provide the name of the language as a value, but its MIME type as defined in RFC2045 (see http://www.faqs.org/rfcs/rfc2045.html for details). For ECMAScript, the type is text/ecmascript; for JavaScript, it is text/javascript. If you want to use Microsoft's JScript (the JavaScript clone) that is available only on the Windows platform, your code would look like this:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint