SoftLookup.com - Welcome to one of the world's biggest and fastest download site. lot of shareware, freeware, utilities, Internet, and desktop software.


Lean CSS
Welcome to CSS
Introduction to CSS
CSS Syntax
Insert style sheet
CSS Background
CSS Text
CSS Font
CSS Border
CSS Margin
CSS Padding
CSS List
CSS Dimensions
CSS Classification
CSS Positioning
CSS classes
CSS elements
CSS2 Media Types
CSS Units
CSS Colors
 

Free Tutorials
HTML
Learn HTML
Learn CSS
Learn XML
Learn WML
Database
Learn Access
Learn Data-VB
Learn Oracle
Learn SQL
Programming
Learn C++
Learn JavaScript
Learn Vbscript
Learn VisualBasic

Chapter 18

Using ActiveX and Microsoft Internet Explorer 3.0


CONTENTS

In this chapter, you're taking a bit of a detour from JavaScript. You will be looking at Microsoft's answer to scripting. This includes the following topics:

  • Using the Microsoft Internet Explorer (MSIE) Web browser, and how it works with JavaScript
  • ActiveX controls, which can be placed on Web pages
  • VBScript, a scripting language supported exclusively (for now) by MSIE

Downloading and Installing Internet Explorer 3.0

Microsoft Internet Explorer (MSIE) is Netscape's greatest competition, and for good reason-it includes many enhancements and is completely free. However, it doesn't support JavaScript completely. Here 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.
  • Along with JavaScript support, which is still being perfected 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 Plug-Ins."
  • 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.

Tip
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 URL:

http://www.microsoft.com/ie/

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.

Note
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 default page.

Figure 18.1 : The initial display of MSIE includes Microsoft's Web page.

Internet Explorer and JavaScript

In this section, you'll take a look at the support for JavaScript in MSIE. Currently, some JavaScript is supported, but not all-perhaps 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 12, "Working with Graphics in JavaScript") have not been implemented.
  • Although the latest MSIE supports Java, the Java/JavaScript connection feature (LiveConnect) is not implemented.
  • Any very complicated JavaScript application is likely to have problems, at least for now.

These problems apply to the current version of MSIE (3.0 beta). Of course, future versions may implement JavaScript better. Because Netscape is still developing JavaScript, Microsoft can't get everything right until it's finished.

Note
Bear in mind that this guide is based on Netscape 3.0's implementation of JavaScript, but MSIE's support more closely matches that of Netscape 2.0. A future version of MSIE will undoubtedly address the 3.0 features.

As one example, Figure 18.2 shows MSIE displaying the Fictional Software Company Web page with the scrolling message example from Chapter 8 "Improving a Web Page with JavaScript." The 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 8.

Using ActiveX Controls

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 name.

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.

Note
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.

How ActiveX Controls Work

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.)

Also unlike JavaScript and Java, ActiveX controls are purely executable 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 easy as JavaScript, or even Java. You need to use the Microsoft C compiler under Windows to create them.

Using an Existing ActiveX Control

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 gradient control.


Listing 18.1. (GRADIENT.asp) An HTML document including an embedded ActiveX control.
<HTML> <HEAD> <TITLE>The ActiveX Gradient Control</TITLE> </HEAD> <BODY> <H1>Gradient Control (ActiveX)</H1> <HR> <OBJECT id=iegrad1 type="application/x-oleobject" classid="clsid:017C99A0-8637-11CF-A3A9-00A0C9034920" codebase="http://www.microsoft.com/ie/download/activex/ iegrad.ocx#Version=4,70,0,1086" width=500 height=50 > <param name="StartColor" value="#ff0000"> <param name="EndColor" value="#0000ff"> <param name="Direction" value = "0"> </OBJECT> <HR> The above is a gradient, produced by the MSIE 3.0 gradient control. </BODY> </HTML>

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 it.
  • 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.

A Sampling of ActiveX Controls and Features

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 section.
  • 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 option causes an event, which can be used with VBScript or JavaScript.
  • 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 method in JavaScript.
  • 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.

Note
All the controls listed are available from Microsoft's Web site. See appendix C, "Online JavaScript Resources," for a listing of other pages with downloadable controls.

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.

Using the ActiveX Control Pad

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:

http://www.microsoft.com/workshop/author/cpad/tutorial-f.asp

Here's what you'll need to use the ActiveX Control Pad:

  • The ActiveX Control Pad works only on Windows 95 or Windows NT 4.0.
  • 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.

Note
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.

Developing ActiveX Controls

Anyone can develop ActiveX controls, although it's not as easy as JavaScript. If you've programmed in C++ before, you will find 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 in beta).

For more information about ActiveX and the SDK, see Microsoft's ActiveX information at this URL:

http://www.microsoft.com/intdev/sdk/

An Introduction to VBScript

One of the latest weapons in Microsoft's war with Netscape is VBScript. VBScript is meant to compete directly with JavaScript, and it includes many of the same features.

You might have noticed that this guide takes 17 chapters to explain JavaScript-of course, VBScript can't be fully explained in one chapter. This section presents the basics of VBScript and shows you how to create a simple VBScript application. You'll also look at some of the key differences between JavaScript and VBScript.

Note
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.

Creating a Simple VBScript Application

Like JavaScript, VBScript is included directly in an HTML file, and it is delimited with the <SCRIPT> tag. A script tag for a VBScript application looks like this:

<SCRIPT LANGUAGE="VBScript">

The actual language is a bit less complex in syntax than JavaScript; there is less punctuation, and many commands are simpler. Like JavaScript, VBScript can have functions, statements, and event handlers.

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.
<HTML> <HEAD><TITLE>A simple VBScript program</TITLE> </HEAD> <BODY> <H1>VBScript Example</H1> <hr> The button below triggers a VBScript function which displays an alert box. <hr> <INPUT TYPE=BUTTON VALUE="Test Button" NAME="Button1"> <SCRIPT LANGUAGE="VBScript"> Sub Button1_OnClick MsgBox "You pressed the button.", 0, "Window title." End Sub </SCRIPT> <hr> End of VBScript function </BODY> </HTML>

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.

VBScript Versus JavaScript

Finally, let's take a quick look at some of the key features of JavaScript and how VBScript compares. This will give you some idea of what you're in for if you decide to learn VBScript as your next Web language.

Punctuation and Syntax

An obvious difference between JavaScript and VBScript is in its 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:

Sub Message(text) MsgBox text End Sub

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.

Variables

Like JavaScript, VBScript is a loosely typed language. There is 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 in JavaScript). This example declares a variable and assigns a string value to it:

Dim Answer Answer = "The answer is 42."

VBScript and Forms

Like JavaScript, VBScript can access all the elements in a form-in 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.

Object-Oriented Features

Although VBScript can access form elements and ActiveX controls as objects, it is not as object-oriented as JavaScript. There is currently no way to create new objects or add properties to existing ones. These may be added in a future version.

ActiveX and VBScript

VBScript can access and control ActiveX controls, similar to the way JavaScript can work with Java. Each ActiveX control is available as an object to scripts in that page. Objects can generate events, and they can call VBScript functions when the events occur.

Workshop Wrap-Up

In this chapter, you learned about Microsoft Internet Explorer, ActiveX, and VBScript:

  • How to download, install, and run MSIE
  • How MSIE handles (or doesn't handle) JavaScript programs
  • What ActiveX controls are, and how they are used
  • How to embed an ActiveX control in a Web page
  • What VBScript is, and how it compares to JavaScript
  • How to create a simple VBScript program

You also explored a sampling of the available ActiveX controls.

Next Steps

Move on with one of the following:

  • To see another example of an ActiveX control in action, see Chapter 19, "Real-Life Examples IV."
  • To learn about other alternatives to JavaScript and the future of scripting on the Web, turn to Chapter 20, "The Future of JavaScript."
  • To learn about Java, another powerful Web language, turn to Chapter 16, "Integrating JavaScript with Java."
  • To find online resources related to JavaScript and VBScript, see appendix C, "Online JavaScript Resources."

Q&A

Q:
If MSIE supports JavaScript and Netscape will support VBScript, which language will be the standard?
A:
Honestly, it's anyone's guess. Of course, Netscape wants JavaScript to be the standard, and Microsoft wants VBScript to be the standard. However, on the Web right now there are many sites using JavaScript and very few using VBScript. Will this change? Who knows.
Q:
Can VBScript be used with Java, as JavaScript can?
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?
A:
Because both MSIE and Netscape support it, at least to a point, JavaScript seems the clear choice right now. JavaScript is also more sophisticated than VBScript. Although MSIE is gaining rapidly, Netscape is still used by about 90 percent of Web users at this writing.






|  About us | Categories | New Releases | Most Popular | Web Tutorial | Free Download | Drivers |



2019 SoftLookup Corp. Privacy Statement