Sams Teach Yourself HTML 4 in 24 Hours

Sams Teach Yourself HTML 4 in 24 Hours

By Dick Oliver

ActiveX Controls

For quite some time, Microsoft Windows has included a feature called object linking and embedding (OLE), which allows all or part of one program to be embedded in a document that you are working on with another program. For example, you can use OLE to put a spreadsheet in a word processing document.

When the Internet explosion rocked the world in the mid-'90s, Microsoft adapted its OLE technology to work with HTML pages online and renamed it ActiveX. Everybody likes to invent his or her own jargon, so ActiveX programs are called controls rather than applets.

Although ActiveX is touted as Java's main competitor, it actually isn't a specific programming language. It's a standard for making programs written in any language conform to the same protocols, so that neither you, the Web page author, nor the people who view your pages need to be aware of the language in which the control was written. It just works, whether the programmer used Visual Basic, VBScript (a simplified version of Visual Basic), C++, or even Java.

It's not surprising that support for the Microsoft ActiveX protocol is built into Microsoft Internet Explorer (versions 3 and later). For users of Netscape Navigator to be able to see ActiveX controls, they need to download and install the ScriptActive plug-in from Ncompass Labs (http://www.ncompasslabs.com).

Because ActiveX is the newest of the technologies discussed in this hour, you must use the new <object> tag to insert it into a page.

As Figure 18.3 shows, an ActiveX <object> tag looks rather bizarre.

18fig03.gif

Figure 18.3 The <object> tag on this page embeds an ActiveX control.

The bizarre part is the classid attribute, which must include a unique identifier for the specific ActiveX control you are including. If you use an automated program, such as Microsoft's ActiveX Control Pad, to create your ActiveX pages, it will figure out this magic number for you. Otherwise, you need to consult the documentation that came with the ActiveX control to find the correct classid.

As if the long string of gibberish in classid weren't enough, the id attribute must include another unique identifier, but this time you get to make it up. You can use any label you want for id, as long as you don't use the same label for another ActiveX control in the same document. (id is used for identifying the control in any scripts you might add to the page.)

The <param /> tags work the same with <object> as they do with the <applet> tag, discussed earlier in this hour: They provide settings and options specific to the particular ActiveX control you are placing on the Web page, with name identifying the type of information and value giving the information itself. In the example from Figure 18.3, <param /> tags are used to specify the alignment, orientation, font, and color of some text to be displayed by the Label control. This is one of many ActiveX controls built into Microsoft Internet Explorer 4 and documented at the Microsoft Developer Network Web site at http://www.microsoft.com. (Internet Explorer 5 automatically downloads the control from the Microsoft Web site upon demand.)

Notice that nothing in the HTML itself gives any clue as to what the ActiveX control on that page actually looks like or does. Only when you view the page, shown in Figure 18.4, do you see that it is a nifty little program that displays rotated text.

18fig04.gif

Figure 18.4 The ActiveX control on this page is a program for displaying fancy text, although you wouldn't know it by looking at the HTML in Figure 18.3.

Share ThisShare This

Informit Network