Using JavaScript in HomeSite 4.0, Part I: Writing Scripts | WebReference

Using JavaScript in HomeSite 4.0, Part I: Writing Scripts

Using JavaScript in HomeSite 4.0, Part I

Writing Scripts

When you execute a script within HomeSite (by clicking one of your custom buttons), the application invokes the script's Main routine. For example, if you're using JavaScript (JScript), your script should have the following structure:

function Main() {

You can also include additional global variables and functions, as shown in the following script:

var app = Application;
function Main() {

Just like C++, HomeSite executes the script by calling the Main() function. Note that the physical position of the function related to other variables and functions doesn't matter. HomeSite executes any global statement in the script file before it executes the Main() function. If you're familiar with the implementation of JavaScript in HTML documents, this behavior will remind you of the onLoad event handler, because it runs only after the entire page has loaded.

We mentioned earlier that HomeSite supports JScript and VBScript. You obviously can't use both languages in one script, so the program must know what language you are using. HomeSite determines which language engine to use based on the extension of the script file. The extensions .bas, .vb, and .vbs refer to VBScript, while any other extension represents a JavaScript source.

Produced by Yehuda Shiran and Tomer Shiran

Created: September 13, 1999
Revised: September 13, 1999