Given by Nancy J. McCracken at CPS616 -- Information Track of CPS on Spring Semester 97. Foils prepared 4 May 97
Outside Index
Summary of Material
This talk is designed to describe the capabilities of ActiveX with VBScript for people who know Java and JavaScript. It will give some examples and mention key features without getting into serious programming details. |
Outline:
|
Outside Index Summary of Material
4/23/97 |
Nancy McCracken |
NPAC |
This talk is designed to describe the capabilities of ActiveX with VBScript for people who know Java and JavaScript. It will give some examples and mention key features without getting into serious programming details. |
Outline:
|
ActiveX has similar functionality to JavaScript and Java in adding dynamic elements to web pages. |
ActiveX is an extension of the OCX controls that are used to interface many Microsoft applications to each other and to the windowing system. |
The controls are programmed in VBScript, which is a subset of Visual Basic, and is familiar to most Microsoft application programmers. |
Reference: "ActiveX and VBScript", by Paul Lomax, Laura Lemay's Web Workshop, sams.net, 1997. |
One advantage to using ActiveX is the built-in authoring tools, both for adding elements (controls) to web pages and for any accompanying VBScripts. |
The major disadvantage is that web pages using ActiveX are recognized only by Microsoft's Internet Explorer, so that they have a limited audience. |
ActiveX would be particularly useful in a corporate environment that already had many applications and OCX controls programmed that would be connected by the web pages, and where the web pages are intended for intranet use, and not general internet use. |
If your web page applications are starting from scratch or are intended for general internet use, then it would probably be better to use Java/JavaScript. |
ActiveX with VBScript combines many of the capabilities of JavaScript and Java:
|
Many useful ActiveX controls and VBScripts, such as using a button to control other elements of the web page, are "built-in" to the Internet Explorer. Other user-written controls would have to be downloaded to the client machine. |
ActiveX controls reside directly on the client machine and do not have the same built-in security restrictions of Java/JavaScript. Before a control is downloaded a "Certificate Page" is presented to the user, giving information about the author or certifiying organization of this control. If the user trusts this author or organization, then he or she can continue the download.
|
Run the ActiveX Control Pad to write HTML pages |
object tag |
use pop-up window to set label properties |
html object tag is automatically generated |
view box is "almost WYSIWYG" |
The insert control menu lists built-in controls |
For each control, the script wizard lists events to select |
Then you specify changes to properties of other elements |
uses the script tag with language VBScript |
event subroutines are automatically generated |
Clicking the button changed the label |
Mouseover the label added text to the status bar |
ActiveX controls are components that extend the capabilities of the web page. They were formerly known as OCX or OLE controls, Microsoft software development. |
An ActiveX control can be programmed in a language such as Visual C++, Visual Basic or Delphi. |
An ActiveX component is designed to be used by some other software (such as a web browser). |
OLE controls interface applications to the windowing system. |
The <object> tag is proposed by the World Wide Web consortium to place an object on a web page. It would replace the current <img> and <applet> tags, as well as the DYNSRC attribute for audio and video, and other proprietary extensions to HTML. |
Attributes of the object tag:
|
Inside the object, the <param> tag can be used for parameters. |
This creates a "spin button" control on the web page: <object id="SpinButton1" width=16 height=32 classid="CLSID:79176FB0-B7F2-11CE-97EF-00AA006D2776"> <param name="Size" value="423;846"> </object> |
The classid says what kind of object it is (CLSID) and enough information for the browser to find the object on the user's Windows system, identify and run the control. |
Parameters are used to set properties of the control. |
The codebase property can be set to a URL if the control is a custom control that the user may need to download. |
Any control can be made into a hyperlink. |
HTML elements are known as "intrinsic controls" and have additional attributes that you can attach scripts to.
|
Similar list of events to JavaScript
|
For communicating with users, there are: Alert Boxes, Message Dialog Boxes, Confirm Boxes, Prompt Boxes, and Custom (Input) Dialog Boxes. |
Build a drop-down menu on your web page. |
A collection of ActiveX Controls is at the Microsoft ActiveX Gallery: http://www.microsoft.com/workshop/ |
Contains controls both from Microsoft and third-party vendors. |
There is also an ActiveX plug-in for Netscape browsers running in a Windows environment. |
This control allows you to design the placement of other controls on the web page.
|
Includes all forms elements plus:
|
VBScript is similar in scope and functionality to JavaScript |
It is a subset of Microsoft Visual Basic for Applications (VBA). |
It can be used to interface both ActiveX controls and Java applets |
It can also be used as stand alone scripts that act directly on browser objects. |
Built-in data types include: Empty, Null, Integer, Long, Single, Double, Date, String, Object, Error |
You may declare data types for variables, or you may leave it to the system to infer a type (variant type): <script language="vbscript"> <!-- Qty = 162 ProductName = "Paper Clip" --> </script> |
A global variable is declared with the keyword dim: dim space dim myArray(9) creates a 10 element array indexed from 0 to 9 |
Object-oriented view, shown in an example script to add the values that the user has typed into two textfields and display it in a third: Sub Button1_OnClick FirstData = CDbl(Document.Form1.Text1.Value) SecondData = CDbl(Document.Form1.Text2.Value) Document.Form1.Text3.Value = FirstData + SecondData End Sub |
Note the Basic (and Fortran-like) syntax that statements are distinguished by being on separate lines. |
Cdbl converts text input string to a double. |
Example using a for loop and an if-then-else for a form with a set of radio buttons named choice1 (note that the loop covers all elements of the form named OrderForm): binSize = False for i = 0 to Document.OrderForm.Elements.Count -1 if Document.OrderForm.Elements(i).Name = "choice1" then if Document.OrderForm.Elements(i).Checked then binSize = True strSize = "Size: " & Document.OrderForm.Elements(i).Value exit for end if end if next |
Notes on previous example:
|
Continuing the example: if not binSize then alert "You must choose a size" end if |
These functions return the current date and time from the client machine: myDate = Date() myTime = Time() |
In addition to various communication controls like alert boxes, you can write directly to the document: Document.Write = Document.LastModified |