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

Using JavaScript in HomeSite 4.0, Part I: Executing Scripts

Using JavaScript in HomeSite 4.0, Part I

Executing Scripts

HomeSite is a very convenient programming language editor, so you'll probably use it to write your scripts. Once you've completed a script, save it on your hard disk with the correct extension. We recommend the common .js extension for JavaScript files. Check to make sure you haven't forgotten the Main() function.

Before you assign the script to a button (a process that often takes over a minute), you'll want to test and debug the script. First, we need to make sure HomeSite is prepared to execute an ActiveScript file in this mode. Right click on one of the toolbars, or select "Customize..." from the "Options" menu:


Now select the "Keyboard Shortcuts" tab at the top of the dialog box. Look for the command called "Execute current document as ActiveScript." You should see the following window:

Keyboard Shortcuts

Make sure a shortcut is assigned to this command. In the above example, the command's shortcut is "Shift+Ctrl+Q." If no shortcut is assigned, use the "Apply" button at the bottom to set a custom shortcut. Once a shortcut has been assigned to this command, you can pass the current document to the ActiveScripting engine, turning the program into a powerful debugging tool (provided, of course, that they start with the Main routine). As with toolbutton-based scripts, the scripting language is determined by the file extension of the current document.

When you're sure the script works flawlessly, it's time to associate it with a toolbutton. Create a new button, as explained in the first section of the column, Customizing Toolbars. Select the fourth type of button ("Execute an ActiveScript file"). You should see the following dialog box:

Execute an ActiveScript File

Enter the name of the script file and the location of the desired button image, which should be an 18x18 BMP file. Alternatively, you can enter a simple caption, consisting of two characters. The optional hint serves as a tooltip (a small yellow text box) when the mouse is placed over the button. The following image shows the result of the above button data:

A Button in Action

Produced by Yehuda Shiran and Tomer Shiran

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