Using ActiveX and Microsoft Internet
You will be looking at Microsoft's answer to scripting. This includes
the following topics:
- Using the Microsoft Internet Explorer (MSIE) Web browser,
- ActiveX controls, which can be placed on Web pages
- VBScript, a scripting language supported exclusively (for
now) by MSIE
Microsoft Internet Explorer (MSIE) is Netscape's greatest competition,
and for good reason-it includes many enhancements and is completely
are some highlights of the features in the latest version:
- The entire HTML 3.2 specification is supported. In addition,
MSIE supports style sheets-a supplement to HTML that enables
you to precisely control the way a page is laid out, without violating
the HTML standard. Netscape has planned support for style sheets
for Navigator 4.0.
at this writing, MSIE 3.0 supports ActiveX and VBScript, which
you'll look at later in this chapter.
- MSIE 3.0 supports the Netscape plug-in specification; most
Netscape plug-ins will work just as well with MSIE. You learned
about plug-ins in Chapter 13, "Working with Multimedia and
- This is the first version of MSIE to fully support frames
and cookies, which you learned about in Chapter 9 "Using
Frames, Cookies, and other Advanced Features."
- An extension to frames enables floating frames-frames
that can be anywhere on the page, rather than simply dividing
the screen. They can also overlap.
- It includes intranet-specific features, such as enabling an
administrator to limit which functions users can access.
- You can follow links without using the mouse. This sounds
minor, but it's something I've wanted to see in Netscape for years.
For more information about MSIE 3.0, ActiveX, and VBScript, take a look at Internet Explorer 3 Unleashed, published by Sams.net.
To begin, you need to download the latest version of MSIE. You
can find the appropriate link to download it by starting at this
The Windows version of MSIE comes in a self-extracting archive
file. To begin the installation, simply click on the file. Note
that, in the current version, MSIE installs on drive C, whether
you want it to or not.
MSIE is available for Windows 95, Windows 3.1, and Macintosh platforms at this writing, although not all platforms have all features available. Consult Microsoft's Web page for further information.
Once installed, you will find an icon to run MSIE on the desktop.
When you first run MSIE, the Microsoft Network page will be loaded
by default, as shown in Figure 18.1. Luckily, you can change the
Figure 18.1 : The initial display of MSIE includes Microsoft's
half of the examples in this guide will work with MSIE. Here are
some of the key features that are missing:
- Event handlers don't seem to work properly in some cases.
- New features, such as data tainting (see Chapter 10, "Working
with Multiple Pages and Data") and dynamic images (Chapter
connection feature (LiveConnect) is not implemented.
problems, at least for now.
These problems apply to the current version of MSIE (3.0 beta).
right until it's finished.
As one example, Figure 18.2 shows MSIE displaying the Fictional
Software Company Web page with the scrolling message example from
scrolling status-line message works fine, but the onMouseOver
events to display friendly link descriptions don't.
Figure 18.2 : MSIE shows the FSC home page from Chapter
One of the latest buzzwords on the Internet today is ActiveX.
ActiveX was developed by Microsoft and is a standard for controls-self-contained
devices with their own functions-that can be placed on Web pages.
If you've heard of Object Linking and Embedding (OLE), you already
know about ActiveX, because they're the same thing. OLE controls
were called OCX controls for a while and are now called ActiveX
controls. By the time you read this, they may already have a new
Regardless of the name, ActiveX controls can be powerful additions
to a Web page. Better still, you can use them without necessarily
knowing how they work. Currently, MSIE is the only browser to
support ActiveX controls, but this will change-a plug-in for Netscape
to support them is already in development, and Netscape has announced
that it will support them in a future version.
As you may have guessed, ActiveX is a Windows-only feature-at least for now. It is unknown whether Microsoft will support other platforms; ActiveX controls rely heavily on the Windows API, so this may never happen.
You can use an ActiveX control anywhere in a Web page using the
<OBJECT> tag, which
you learn about in the next section. ActiveX controls work similarly
to Java-they are embedded in the page and perform a specific function.
Compared to Java, though, they're more integrated with HTML.
Unlike Java, an ActiveX control can be permanently installed on
your machine, making it available for future use. When you access
a page with a control, it attempts to use an installed control.
If you don't have the control installed, it downloads and installs
it automatically. (It does inform you that it's doing this.)
code-they are handled by the operating system directly, and little
work is done by the browser.
These controls can be quite large and complicated. They can be
used to add functionality to the browser, similar to Netscape
plug-ins. For example, the current version of MSIE implements
the Java virtual machine as an ActiveX control.
You can create your own ActiveX controls-however, it's not as
C compiler under Windows to create them.
Microsoft added the <OBJECT>
tag to its implementation of HTML to support ActiveX controls.
This tag works like Java's <APPLET>
tag-it specifies the control to load and can optionally include
parameters to be sent to the control.
As an example, Listing 18.1 shows an HTML file that embeds an
ActiveX control. This control is the gradient control, which displays
a range of colors in an area. Figure 18.3 shows the result of
loading this page in MSIE.
Figure 18.3 : MSIE shows the HTML document with the embedded
Listing 18.1. (GRADIENT.asp) An HTML document including an
embedded ActiveX control.
<TITLE>The ActiveX Gradient Control</TITLE>
<H1>Gradient Control (ActiveX)</H1>
width=500 height=50 >
<param name="StartColor" value="#ff0000">
<param name="EndColor" value="#0000ff">
<param name="Direction" value = "0">
The above is a gradient, produced by the MSIE 3.0 gradient control.
Here is an explanation of the parameters used here:
- The <OBJECT> tag
begins the object definition.
- The id is an identifying
name for the object, and type
is the MIME type (for an OLE object).
- classid is the class
ID-a rather large number specific to this control.
- codebase is where the
control can be downloaded from, in case the user doesn't have
- width and height
allocate an area for the control. This works the same as the corresponding
attributes in an image tag.
- StartColor, EndColor,
and Direction are parameters
to be passed to the control. In this case, they control the starting
and ending colors and the direction of the gradient.
It would be difficult to cover all the available ActiveX controls,
because there are so many-and more are being developed daily.
In this section, you'll take a look at some of the controls available
from Microsoft. This should give you an idea of the types of things
that are possible with ActiveX:
- Animated Button enables you to include buttons with animated
displays in a page. For example, the button might look "pressed
in" when you click on it.
- Chart displays pie, line, and other types of charts within
a Web page. The data to be charted is stored in a separate file
on the Web server. Figure 18.4 shows an example of this control
in action on one of Microsoft's Web pages.
- Gradient displays a block of color, ranging from one color
to another. This control was used in the example in the previous
- Label displays text, but at any angle, or even a curve. This
can be useful for labeling a figure or control.
- New Item enables you to display "new" icons automatically
next to links on your page. A parameter enables you to specify
a date, and after that date the icon is not displayed.
- Pop-up Menu displays a pop-up menu of options. Selecting an
- Pre-loader enables a page to be loaded into the cache, but
not displayed until you specifically request it.
- Stock Ticker downloads data from the URL you specify at regular
intervals and displays it in an area of the page. This is useful
for changing information, such as stock prices.
- Timer waits a specified time, then causes an event. This is
similar to the setTimeout
- PowerPoint Animation Player plays Microsoft PowerPoint animations
within a page-an easy way to make animations, if you have PowerPoint.
Figure 18.4 : The ActiveX Chart control enables you to
display graphs and charts within Web pages.
As you can see, just about anything can be done with ActiveX controls.
There's a price, however-some of the controls can be quite slow,
and downloading a new control can be even slower. You'll also
have to consider whether you want non-Windows users to be able
to view your page.
You don't have to understand ActiveX-or even HTML-to use an ActiveX
control in a Web page of your own. Microsoft has made it easy
with a product called the ActiveX Control Pad. This includes a
text editor for the HTML page, as well as dialogs to control the
properties of ActiveX controls.
To find out more about the ActiveX Control Pad and download it,
see this page at Microsoft's Web site:
Here's what you'll need to use the ActiveX Control Pad:
- The ActiveX Control Pad works only on Windows 95 or Windows
- You must install MSIE 3.0 (beta 2 or later) before you install
the control pad.
Once you install the control pad, you can begin to use it. Note
that it's best to be online while using it so that it can access
ActiveX control definitions if necessary.
The main screen includes a text editor; you can load any HTML
page into this window. You can use the Insert ActiveX Control
command from the Edit menu to insert a control. If you already
have an existing control in the page, an icon will be shown next
to the <OBJECT> tag.
Clicking a control's icon shows the control in action, along with
a dialog that lists the properties for the control and enables
you to change them. This is shown in Figure 18.5.
Figure 18.5 : The ActiveX Control Pad shows an HTML document,
ActiveX control, and properties list.
Once you accept the properties you have selected, the appropriate
tags are inserted into the HTML document to set those parameters
for the control. It's that simple.
The ActiveX Control Pad can be used with any ActiveX control. However, you must be licensed to use the control. Many controls can be used freely; with others, you may have to purchase a license to use them in your own pages.
Anyone can develop ActiveX controls, although it's not as easy
it easy. Here's what you need to develop your own ActiveX controls:
- You can write ActiveX controls in any language-if you have
an ActiveX-compatible compiler. Currently, the only such compiler
is Microsoft Visual C++ version 4.1.
- The ActiveX SDK (Software Development Kit) includes everything
you need (except the compiler) to get started. It's available
at no cost from Microsoft.
- Currently, the SDK works with Windows 95 or Windows NT 4 (currently
For more information about ActiveX and the SDK, see Microsoft's
ActiveX information at this URL:
One of the latest weapons in Microsoft's war with Netscape is
and it includes many of the same features.
You might have noticed that this guide takes 17 chapters to explain
chapter. This section presents the basics of VBScript and shows
you how to create a simple VBScript application. You'll also look
To learn more about VBScript, consult Microsoft's online documentation or get a copy of Teach Yourself VBScript in 21 Days by Brophy and Koets, published by Sams.net. appendix D of this guide includes a list of online references to get you started.
and it is delimited with the <SCRIPT>
tag. A script tag for a VBScript application looks like this:
there is less punctuation, and many commands are simpler. Like
Because VBScript is a subset of Visual Basic, you may find it
easy to learn if you've used Visual Basic before. However, there
are many differences, so don't assume you already know everything.
As an introduction to VBScript, Listing 18.2 shows a simple VBScript
application. The page includes a button; pressing the button causes
an alert box (or message box, in VBScript lingo) to be displayed.
Listing 18.2. (VBSCRIPT.asp) A simple VBScript application.
<HEAD><TITLE>A simple VBScript program</TITLE>
The button below triggers a VBScript function which displays
an alert box.
<INPUT TYPE=BUTTON VALUE="Test Button" NAME="Button1">
MsgBox "You pressed the button.", 0, "Window title."
End of VBScript function
Figure 18.6 shows this program in action, with the message box
displayed. Notice that rather than using an event handler attribute
on the button tag, the procedure's name specifies the button's
name and the event handler name.
Figure 18.6 : The VBScript example in action.
Finally, let's take a quick look at some of the key features of
idea of what you're in for if you decide to learn VBScript as
your next Web language.
use of basic punctuation and syntax. VBScript does not use semicolons
or brackets at all. Function declarations and other blocks of
code, such as loops, are enclosed with beginning and ending statements.
For example, here is a procedure definition:
This syntax is used for a procedure-a function that doesn't
return a value. The Function
keyword is used for functions that do return a value.
one variable type, called Variant,
that can hold a number, a string, or other types of values. Variables
must be declared with the Dim
statement (similar to Var
string value to it:
Answer = "The answer is 42."
fact, the syntax is strikingly similar. This is the VBScript syntax
to refer to the text1 input
field in the form1 form:
val = Document.form1.text1.value
VBScript can be used for form validation and can prevent form
submission while fields are not filled in correctly.
Although VBScript can access form elements and ActiveX controls
is currently no way to create new objects or add properties to
existing ones. These may be added in a future version.
VBScript can access and control ActiveX controls, similar to the
as an object to scripts in that page. Objects can generate events,
and they can call VBScript functions when the events occur.
In this chapter, you learned about Microsoft Internet Explorer,
ActiveX, and VBScript:
- How to download, install, and run MSIE
- What ActiveX controls are, and how they are used
- How to embed an ActiveX control in a Web page
- How to create a simple VBScript program
You also explored a sampling of the available ActiveX controls.
Move on with one of the following:
- To see another example of an ActiveX control in action, see
Chapter 19, "Real-Life Examples IV."
of scripting on the Web, turn to Chapter 20, "The Future
- To learn about Java, another powerful Web language, turn to
|A:||Yes, according to Microsoft. The Java support in the latest MSIE is still in beta, though, and I haven't seen a working example of this yet.
|Q:||Which language should I use in my Web pages?
gaining rapidly, Netscape is still used by about 90 percent of Web users at this writing.