Appendix A. ECMAScript overview

ECMAScript, an offshoot of JavaScript, is a lightweight scripting language. It was originally designed to allow Web designers to author simple client-side code to be executed in a Web browser. This code typically manipulated objects in an HTML document based on user events - for example, changing the image on a button when the user rolled the mouse over it.

Instead of reinventing the wheel, the VoiceXML committee decided to use ECMAScript wherever scripting was needed. Some examples are:

script elements

These are blocks of ECMAScript to be executed by the VoiceXML interpreter.

if and elseif conditions

The cond attribute of the if and elseif elements contains an ECMAScript expression that evaluates to a boolean.

cond attributes

Several other VoiceXML elements, including prompt and catch, have cond attributes indicating whether or not the element should be executed.

form items

Each form item is stored as an ECMAScript variable. Each form item also has an expr attribute containing an ECMAScript expression representing the default value for this form item, and a cond attribute containing an ECMAScript expression that evaluates to either true or false indicating whether or not the form item should be visited.

expr attributes

Many other VoiceXML elements have attributes that contain ECMAScript expressions, such as the expr attributes of the var, assign, value, choice, param, link, and audio elements.

throw

The throw element allows both the name of the event being thrown and the message associated with that event to be generated dynamically using ECMAScript expressions.

Therefore, a VoiceXML programmer needs a basic understanding of ECMAScript syntax. This appendix is intended to get you started with ECMAScript. However, it will not exhaustively cover the language. For a rigorous definition of the language, refer to the specification (and other information) at http://www.ecma.ch/ecma1/STAND/ECMA-262.HTM. Also useful is this introduction to ECMAScript's parent-language, JavaScript: http://www.mozilla.org/js. You'll find most of what is here applicable to your ECMAScript programming in VoiceXML.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.156.107