Including An External Javascript File; Calling Javascript Library Functions - Adobe GoLive CS2 Programmer's Manual

Hide thumbs Also See for GoLive CS2:
Table of Contents

Advertisement

SDK Programmer's Guide
In your extension, use the src attribute of the <script> tag to import external JavaScript libraries;
see
Including an external JavaScript

Including an external JavaScript file

An extension's JavaScript code appears between <script> and </script> pairs in the Main.html file.
Use the optional src attribute to the <script> tag to include the contents of an external JavaScript file
in a Main.html file.
<script [src=
The src attribute holds a string value that is a relative URL from the Main.html file to a .js file on the
local file system. The included JavaScript file must reside on the local file system. A URL reference to a file
residing on a remote server is not a valid src attribute value.
The external library is like a C-language #include . When the SDK interprets this attribute, it behaves as if
the .js file had been pasted into the body of the <script> element at this point. JavaScript code
appearing between the <script> and </script> tags in the Main.html file executes after code
provided by the src attribute.
JavaScript in the Main.html file overwrites same-named entities defined by the external file. For
example, if both files define a myFunction function, the function the Main.html file defines replaces
the one the external .js file defines.

Calling JavaScript library functions

You need not use any special calling syntax to call externally defined JavaScript functions. GoLive makes
external JavaScript library functions available to the scripts of an extension as if they were part of the
extension.
The functions an external JavaScript library provides can be called by any extension. Each extension that
includes the external library loads its own copy of the library when GoLive opens. That copy of the library
remains in memory until the module is unloaded. The module is unloaded:
When GoLive quits.
When the user chooses the Reload Scripts palette menu item.
When the moduleObject .unload() JavaScript function is called.
Note:
The unload function destroys its module's global data. The next time a function in the library is
called, GoLive reloads the module and creates new global data for it.
Adobe GoLive CS2 SDK
file.
JavaScriptCode
] >
</script>
Using External Libraries
180

Advertisement

Table of Contents
loading

Table of Contents