User Guide
605
ADOBE GOLIVE CS2
User Guide
JavaScript sample code and result
• The document.write() method on the “Your Local Time” line writes an H1-formatted text string from the
document to the screen of the browser.
• The new Date() method createsanewdateobjectcontainingthe long versionofthe currentdatefromthe viewer’s
operating system. This object is assigned to
currtime.
• The last line is output to the browser’s screen using a document.write() method, with the embedded currtime
variable set to the current time and date.
JavaScript libraries
Shifting code to an external library
GoLive can automatically create an external JavaScript library file that stores shared code from JavaScript actions,
rollovers, dynamic components, and animated scenes created in the DHTML Timeline Editor. At the same time, it
replaces the shared code in the page with a reference to the library file, leaving only page-specific declarations and
parameters in place. Thelibrary is then uploaded to theweb server to make it availablefor everypageinthe site that
needs the script.
Benefits of using external JavaScript libraries
Apart from streamlining the code in your pages, this library offers two advantages:
• It remedies a problem associated with the structure of dynamic GoLive components: GoLive invariably places
common code for DHTML items and actions in the head section of a page. While this structure works well with
“straight” pages, problems could occur in earlier versions when a dynamic component contained DHTML items
and scripted actions. As the browser loads only the body section of a dynamic component, it ignores any script
code contained in the head section. This problem can be solved by using the external JavaScript library, making
JavaScript code in dynamic components work as expected.
• Thebrowser caches theJavaScriptlibrary file andlesscodeiswritten into everypage, making thepages load faster.
The JavaScript library
You can choose the external JavaScript library feature on a per-page basis, as a site-wide setting, or as an application-
wide preference. If you choose the option in the application preferences or site settings, all new pages and existing
pages without preexisting JavaScript will use the new preference setting. Pages that already had actions and other
JavaScript added to them will retain their existing JavaScript Functions setting. You must change the setting for these
pages in the HTML tab of the Page Inspector.










