Host your site on our high performance virtual domain and non-domain accounts.
|
Using ActiveX on the web Published on 9/30/97 ActiveX controls are reusable software components that can be used to add special functions to web sites or desktop applications. This article will focus on applying ActiveX to Internet web pages. Microsoft Internet Explorer 3.0 or higher is the only browser that has native support for ActiveX technology. As this page loaded, you may have been prompted to install several ActiveX components. This only would have occurred if the controls used in this article aren't already on your system. If you are concerned about security, consider reading our article, ActiveX: A Security Risk?. If you declined the installation, our demonstrations will not function properly. However, once these ActiveX controls are on your system, you won't have to download them again, even when you come across them on other web sites. Basically, an ActiveX control is added to a web page using the <OBJECT> and </OBJECT> container tags. There are many attributes that go along with these tags, such as ID, CLASSID, CODEBASE, TYPE, WIDTH, HEIGHT, and ALIGN. The ID attribute can be set to whatever you want, and is used to identify the control for use with scripts in your web page. The CLASSID is unique to each ActiveX component; it is by the CLASSID that you specify which control you are using. Additionally, the CODEBASE attribute can be set to the Internet location of the control itself (usually a file with the .ocx extension). This allows the browser to automatically download and install the control on your visitors' systems. The TYPE attribute is optional and will almost always be set to "application/x-oleobject," which is the MIME type for ActiveX controls. The three remaining attributes are fairly self-explanatory. WIDTH and HEIGHT are used to set the control's visual dimensions on the page, and the ALIGN attribute sets the control's relative position. The use of these tags and attributes will become clear when you see them action. Aside from the <OBJECT> tag's various attributes, you also need to include <PARAM> tags within the <OBJECT></OBJECT> element. The <PARAM> tags have two attributes, NAME and VALUE. You use the NAME attribute to specify one of the control's properties, and the VALUE attribute to set it's value. The properties available to an ActiveX component vary from control to control. Again, this will become clearer when you look at actual examples. We will present three separate ActiveX demonstrations. The first will simply be a control that displays information on the page, without any scripting. The second example will involve a simple VBScript. For more information on this type of scripting, you can read our Using VBScript article. The final example uses a combination of two controls; one of which is not visible on the page. Demonstration #1 Control name: Label Demonstration:
HTML code:
Notes: As you probably noticed, there are many <PARAM> tags associated with this ActiveX control. Also note that the <FONT SIZE="1" FACE="Verdana"> . . . </FONT> section of code is only displayed when the browser does not load the control. You can use any HTML you want in its place. Demonstration #2 Control name: Label Demonstration:
HTML code:
Notes: This time, we needed to include a few form elements--the buttons--in our demonstration. We also used a simple VBScript to control the ActiveX component. The script responds to each button and correspondingly changes the Caption property of the control. Demonstration #3 Control name: Label Control name: Timer Demonstration:
HTML code:
Notes: This example uses two ActiveX controls and a short VBScript. The Timer control is invisible on the page, but its Timer event is used by the script to modify the Label control. The script executes every Timer interval, which is 100 milliseconds in this case. The Label and Timer controls are obviously not the most sophisticated
ActiveX components that you can use. There are many other controls available for download,
or you can make your own using a variety of commercial software development packages. You
can look at c|net's ActiveX web site at http://www.activex.com
|
| Home | About | Feedback
| Downloads | Search Copyright © Michael Yigdall and Jonathan Strine |