Using JavaScript in HomeSite 4.0, Part I: What is ActiveScript?
Using JavaScript in HomeSite 4.0, Part I
What is ActiveScript?
A custom button can execute a script written in JScript or VBScript. Microsoft's version of JavaScript, named JScript, normally runs in Internet Explorer. However, JScript is a global scripting language that receives its local objects from the execution environment. For example, if you execute a script in Internet Explorer, it correlates with the DOM (the Document Object Model). The same applies to Microsoft's Visual Basic Script.
JScript and VBScript are both members of Windows Script, Microsoft's native scripting engine. The entire package consists of Visual Basic Script Edition (VBScript) 5.0, JScript 5.0, Windows Script Components, Windows Script Host 1.0, and Windows Script Runtime 5.0. Any Windows-based application can take advantage of Windows Script if it is installed. The application simply needs to provide a local object model with which the script can handle the corresponding environment.
In order to get started, you must make sure you already have Windows Script on your machine. If you have Internet Explorer 4.0 or later on your system, then you already have the correct ActiveScripting engine installed. For the most recent features, you may want to download the latest version of Windows Script. The installed version of Windows Script applies to all of your Windows applications, including Internet Explorer. Windows Script only provides the core objects of the language, such as String
, Math
, and Date
. It doesn't include other well-known objects, such as window
, document
, and location
, because they belong to a specific environment (Internet Explorer). Windows Script includes the scripting language itself, including keywords, operators, and other global statements. In general, there are three separate classes of objects available within JScript or VBScript:
- Built-in objects provided by the language engine (e.g.,
String
,Math
,Date
). - User-defined objects created by the script author.
- Objects provided by the application (e.g., Internet Explorer, HomeSite).
In this column we'll show you how HomeSite 4.0 enables you to use ActiveScript (Windows Script) to create custom buttons. HomeSite 4.0 provides a set of useful objects: Application
, ActiveDocument
, and DocumentCache
. A few more objects are also supported, but you won't need them to create useful custom ActiveScript buttons. You now know enough to start working with ActiveScript, but you may want to keep reading for a better understanding of Microsoft's scripting engines.
How Does a Software Developer Include JScript or VBScript in an Application?
A software developer can license Microsoft JScript or Microsoft Visual Basic Scripting Edition from Microsoft to use as the scripting language in an application. JScript and VBScript are available from Microsoft in two forms: as a ready-to-run (compiled) binary for several platforms, or as source code. The software developer doesn't have to own his own copy of JScript or VBScript, because users can download the JScript and VBScript binaries from the Microsoft's site. HomeSite 4.0, for example, takes advantage of JScript and VBScript, but it doesn't include these languages. The user can download the binaries from the Web. However, many users won't need to download these binaries, because they are bundled in Internet Explorer 4.0 and later.
The users of an application can download the latest version of JScript and VBScript at any time, giving them the newest features, improved performance, and latest bug fixes, all without any effort on your part. Therefore, if you're running into problems with JScript or VBScript in your scripts, you should consider downloading the latest versions of these languages.
A software developer can add his own objects and run-time functions to JScript and VBScript, without having to modify these scripting languages. These languages serve as "black boxes" of functionality. The implementation of the script itself (language, syntax, execution model, etc.) is left to the script vendor.
Applications using the JScript and VBScript binaries all share a single copy of the DLL in memory. This means that the working set of the application is smaller since it is sharing JScript and VBScript with other applications, such as Internet Explorer.
A software developer can integrate the JScript and VBScript binary into an application using ActiveX Scripting, an open standard that can be used by any scripting language. The result is that the application is not tied to a particular scripting language, and the users can choose which scripting language to use. This is the case of HomeSite. You can choose either JScript or VBScript to write your scripts.
The easiest way to include JScript and VBScript in an application is the Microsoft Script Control. For more information on this control, refer to Microsoft's documentation. As you can see, we've gone way past the scope of our column with this in-depth explanation of Windows Script. It's now time to put our feet back on the ground with HomeSite's implementation of Windows Script.
Produced by Yehuda Shiran and Tomer Shiran
Created: September 13, 1999
Revised: September 13, 1999
URL: https://www.webreference.com/js/column48/activescript.html