Table of Contents

< script >

Description

The <script> element includes a block of client-side script. Each <script> element is executed in the scope of its containing element; i.e., it does not have its own scope. Variables defined in the <script> element are equivalent to variables defined using <var> within the same scope.

Syntax

<script
src="URI"
charset="Encoding"
fetchhint="prefetch" | "safe"
fetchtimeout="time_interval"
maxage="time_interval"
maxstale="time_interval">
Script Text
</script>

Attributes

srcThe src attribute is the URI specifying the location of the external script. This attribute is optional.
charsetThe charset attribute is character encoding if external script is used. This attribute is optional.
fetchtimeoutThe fetchtimeout attribute is the time interval to wait for audio file to be fetched before playing the alternate content. This attribute is optional.
fetchhintThe fetchhint defines when the audio file should be retrieved. This attribute is optional.
* prefetch – the audio file may be downloaded when the page is loaded.
* safe – the audio file loads only when needed.
maxageThe maxage attribute indicates the maximum time in seconds that this document will use this script file before fetching another copy. This attribute is optional.
maxstaleThe maxstale attribute indicates the maximum time in seconds that this document will use a script file that has exceeded the maxage time. This attribute is optional.

Parents

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

Children

None.

Extensions

None.

Limitations/Restrictions

None.

Example Code

<?xml version="1.0"?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
 <script>
 <![CDATA[
   function alwaysTrue() {
   // no need to escape the following less than sign
   return 1 < 2;
   }
 ]]>
 </script>
 <block>
  <prompt>
   Hello
  </prompt>
  <prompt cond="alwaysTrue">
   I am always here
  </prompt>
 </block>
</vxml>

NOTE:

It is wise to put CDATA escapes around your scripts so you don't have to escape XML reserved characters (eg. <, >, &, etc).