Voxeo Documentation - <script> Element

The <script> element is used to specify a block of client-side ECMAScript code.

Syntax

The following code examples show the syntax for the <script> element.

<script charset="myCharSetCDATA" fetchhint="safe" fetchtimeout="myFetchTimeoutCDATA" maxage="myMaxAgeCDATA" maxstale="myMaxStaleCDATA" src="mySrcURI">

- or -

<script charset="myCharSetCDATA" fetchhint="safe" fetchtimeout="myFetchTimeoutCDATA" maxage="myMaxAgeCDATA" maxstale="myMaxStaleCDATA" srcexpr="mySrcExprCDATA">

Attribute Details

The following table describes the attributes for the <script> element.

charset

Required: false

Type: CDATA

Default: UTF-8

Specifies the character encoding of the script contained within the element.

fetchhint

Required: false

Type: prefetch | safe

Default: safe

Specifies when the resource should be fetched during application execution. The following values are permitted:

 

prefetch - Begin the resource fetch upon initial document execution

 
 

safe - Only fetch the resource when it is specifically called in the application

 

fetchtimeout

Required: false

Type: CDATA

Default: 5s

Specifies how long, in seconds or milliseconds, the interpreter should wait for the content to be returned before reverting to any backup TTS, if present, or before the application execution skips the contents of the <audio> element, if no backup TTS is present.

Valid Values: A character string in CSS2 format.

maxage

Required: false

Type: CDATA

Default: none

Specifies the maximum acceptable age, in seconds, of the resource in question.

We do not recommend that you rely on this attribute for cache control; caching is always best controlled by the response headers of the hosting server. If no headers are specified, then no cache control is present, regardless of the value set for the maxage attribute.

Valid Values: An ECMAScript Expression that returns a valid time value for the request.

maxstale

Required: false

Type: CDATA

Default: none

Specifies the maximum acceptable staleness, in seconds, of the resource in question.

We do not recommend that you rely on this attribute for cache control; caching is always best controlled by the response headers of the hosting server. If no headers are specified, then no cache control is present, regardless of the value set for the maxstale attribute.

Valid Values: An ECMAScript Expression that returns a valid time value for the request.

src

Required: false

Type: URI

Default: none

Specifies the URI for the external script content.

Constraints: Exactly one of the src and srcexpr attributes may be specified. The src attribute may not be specified in conjunction with inline script content.

srcexpr

Required: false

Type: CDATA

Default: none

Specifies an ECMAScript expression that evaluates to the URI for the external script content.

Constraints: Exactly one of the src and srcexpr attributes may be specified. The srcexpr attribute may not be specified in conjunction with inline script content.

Shadow Variables

None.

Parents

<block> <catch> <error> <filled> <form> <help> <if> <noinput> <nomatch> <vxml>

Children

None.

Code Samples

The following code samples show use of the <script> element.

// MyScript.js

function ruleFunction() {

return ("here is a nifty little sample script");

}

 

<-- Script maxage-maxstale sample -->

<?xml version="1.0" encoding="UTF-8"?>

<vxml version="2.1">

 

<form id="F1">

<block>

<script src="MyScript.js" maxage="5000" maxstale="5000" />

 

<prompt>

<value expr="ruleFunction()" />

</prompt>

</block>

</form>

</vxml>

 

<!-- Script fetchhint-fetchtimeout sample -->

<?xml version="1.0" encoding="UTF-8"?>

<vxml version="2.1">

 

<form id="F1">

<block>

<script src="MyScript.js" fetchhint="prefetch" fetchtimeout="10s" />

 

<prompt>

<value expr="ruleFunction()" />

</prompt>

</block>

</form>

</vxml>

See Also

VoiceXML Development Guide v2.1 Overview

Element Summary

Voxeo Support

 

The <script> element is used to specify a block of client-side ECMAScript code. For more information, see <script> Element.

 

The <script> element is used to specify a block of client-side ECMAScript code. For more information, see <script> Element.

 

The <script> element is used to specify a block of client-side ECMAScript code. For more information, see <script> Element.

 
A specific character string that represents both a reference to an Internet resource, a URL, the name of an object such as web page, file, and so forth, called a URN. The acronym for uniform resource identifier is URI. Combined, the URL and a URN define a URI.
 

URL - http://help.voxeo.com or http://www.voxeo.com

 
 

URI - http://help.voxeo.com/helpserver/go/help/Support.welcome.htm where the URN is the /helpserver/go/help/Support.welcome.htm portion of the URI

 
 

The <block> element is a form-item container element for executable content. For more information, see <block> Element.

 

The <catch> element is used to intercept application and user-defined errors, conditions, and messages, allowing the developer to assign event handlers on a scoped basis. For more information, see <catch> Element.

 

The <error> element is shorthand for the <catch event="error"> element, and catches all events that begin with error. For more information, see <error> Element.

 

The <filled> element specifies actions to take when a grammar match occurs. For more information, see <filled> Element.

 

The <form> element is a container for all field items, such as a <field> element or a <subdialog> element, and for all control items, such as a <block> element or an <initial> element. For more information, see <form> Element.

 

The <help> element is shorthand for the <catch event="help"> element, and catches all help events. For more information, see <help> Element.

 

The <if> element provides a method to utilize conditional logic expressions to change the control flow within the application based on user utterances, variable values, or events. For more information, see <if> Element.

 

The <noinput> element is shorthand for the <catch event="noinput"> element. This element allows the developer to assign event handlers for when the application expects voice or DTMF input, but has received none from the caller. For more information, see <noinput> Element.

 

The <nomatch> element is shorthand for the <catch event="nomatch"> element. This element allows the developer to assign handlers for when the caller inputs a value that is not recognized by any of the active grammars. For more information, see <nomatch> Element.

 

The <vxml> element is the initial declaration that defines a document as a VoiceXML application. For more information, see <vxml> Element.

 

The <script> element is used to specify a block of client-side ECMAScript code. For more information, see <script> Element.

Voxeo Documentation

     Voxeo Documentation Overview
  Evolution Developer Portal
  Voxeo CXP
  Prophecy
  Development Languages
     Development Languages Overview
  VoiceXML 2.1 Development Guide
     VoiceXML Development Guide v2.1 Overview
     Platform Overview
     Creating an Application
     Voxeo File Manager
     Caching Tips and Techniques
     Cache Manager API
     Security Information
  Learning VoiceXML 2.1
  Best Practices
  Debugging Techniques
  Exceptions and Errors
  VoiceXML 2.1 Porting Guide
  VoiceXML Variables
  All Things Audio
  Outbound Dialing
  Property Guide
  GSL Grammars
  grXML Grammars
     Custom Features
     External References
  Text-To-Speech Guide
     VoIP Dialing
     Voxeo Designer User Interface
  Element Reference Guide
     Element Summary
     <assign> Element
     <audio> Element
     <block> Element
     <break> Element
     <catch> Element
     <choice> Element
     <clear> Element
     <data> Element
     <disconnect> Element
     <else> Element
     <elseif> Element
     <emphasis> Element
     <enumerate> Element
     <error> Element
     <example> Element
     <exit> Element
     <field> Element
     <filled> Element
     <foreach> Element
     <form> Element
     <goto> Element
     <grammar> Element
     <help> Element
     <if> Element
     <initial> Element
     <item> Element
     <link> Element
     <log> Element
     <mark> Element
     <media> Element
     <menu> Element
     <meta> Element
     <noinput> Element
     <nomatch> Element
     <one-of> Element
     <option> Element
     <paragraph> Element
     <param> Element
     <phoneme> Element
     <prompt> Element
     <property> Element
     <prosody> Element
     <record> Element
     <reprompt> Element
     <return> Element
     <rule> Element
     <ruleref> Element
     <say-as> Element
     <script> Element
     <sentence> Element
     <sub> Element
     <subdialog> Element
     <submit> Element
     <tag> Element
     <throw> Element
     <token> Element
     <transfer> Element
     <value> Element
     <var> Element
     <voxeo:logcontrol> Element
     <voxeo:recordcall> Element
     <vxml> Element
  CCXML 1.0 Development Guide
     CallXML 3.0 Development Guide
  Voxeo Support
     Support Quick Reference
  Registering for an Account
  Self-Help Tools
  Collecting Information
  Evolution Ticketing System
     Submitting a Support Request
     Escalating a Support Request
  Software Lifecycle and Support Policies
  Getting Further Assistance
  Voxeo Glossary
  Help on Help