The script element contains JavaScript code that is
executed when the application is loaded. This element must be at the
canvas level; that is, it cannot be contained within any
subordinate tag. If the src attribute is
present, it names a JavaScript file whose contents are compiled into
the application.
In the example below, we add a method to the built-in
Array class that will let us find the index of
elements in an array. Note that Array.find uses
=== for finding, so that two objects that are similar
will not be confused. This is why looking for {example:
'sneaky'} finds nothing, whereas looking for
sneaky succeeds.
<canvas debug="true" height="200">
<debug y="5%" height="90%"/>
<script><![CDATA[
// Add a find method to Array
Array.prototype.find = function ( what ) {
for (var i = 0; i < this.length; ++i) {
if (this[i] === what) {
return i;
}
}
}
var sneaky = {example: 'sneaky'};
var tryit = ['foo', 42, sneaky, Math.PI, false];
Debug.format("42 is at: %s\n", tryit.find(42));
Debug.format("false is at: %s\n", tryit.find(false));
Debug.format("'bar' is at: %s\n", tryit.find('bar'));
Debug.format("{example: 'sneaky'} is at: %s\n", tryit.find({example: 'sneaky'}));
Debug.format("sneaky is at: %s\n", tryit.find(sneaky));
]]></script>
</canvas>
| Name (CSS property) | Type (tag) | Type (js) | Default | Category |
|---|---|---|---|---|
src
|
string | String | initialize-only | |
The pathname of a Javascript file. This pathname is resolved
relative to the file that contains the
<script> element.
|
||||
classroot, cloneManager, data, datapath, defaultplacement, id, ignoreplacement, immediateparent, inited, initstage, name, nodeLevel, options, parent, placement, styleclass, subnodes, transition
Methods
animate, applyConstraintMethod, applyData, childOf, completeInstantiation, construct, createChildren, dataBindAttribute, destroy, determinePlacement, getOption, getUID, init, lookupSourceLocator, releaseConstraint, releaseConstraintMethod, searchImmediateSubnodes, searchSubnodes, setOption, setSelected, updateData
Events
Copyright © 2002-2010 Laszlo Systems, Inc. All Rights Reserved. Unauthorized use, duplication or distribution is strictly prohibited. This is the proprietary information of Laszlo Systems, Inc. Use is subject to license terms.