script

Purpose

Used to contain or refer to a script.

Note:

Contained scripts are deprecated, but are supported for backward compatibility. You should use the src attribute to refer to a script policy or file.

Attribute groups

Attributes

Attribute Description Type Default Options Use
charSet Character encoding of the script if a script is in a file xs:string none    optional 
defer A hint that the script will not generate output. If set to 'true', execution can be deferred. xs:boolean none    optional 
language The language of the script if a script file xs:string none    deprecated 
src Name of script policy or location of an external script file xs:string none    optional 
type The content type of the script if a script file xs:string none    optional 

Examples

The first example refers to a script policy.

<?xml version="1.0" encoding="UTF-8"?>
<canvas layoutName="/welcome.mlyt" pageTitle="script">
  <pane name="background">
    <h3>Welcome</h3>
    <script id="scripttest" src="{/script.mscr}"/>
  </pane>
</canvas>

The script.mscr policy contains the following JavaScript code:

alert("This text has been generated by the script.mscr script policy.");

The second example refers to a script file and uses the type attribute.

<script
  src="../scripts/release.js"
  type="text/javascript"/>

Related topics