Microsoft has developed another technology that is heating up the action in the browser war. ActiveX controls are reusable components that add special functions to your Web pages. What makes them different, however, is that you can use the same controls in software programs. This allows content developers to create Web pages and applications that work together. Nice stuff. With ActiveX, you can add form fields, enhanced navigation controls, animation and multimedia, credit card transactions, spreadsheet calculations, database communications, and more to your Web pages. Thousands of ActiveX controls are published by many third-party software vendors. Internet Explorer 3.0 has ActiveX technology built in to the browser. Other browsers are sure to add ActiveX capabilities through the use of plug-ins.
FrontPage also allows you to insert scripts into your pages, using either VBScript or JavaScript. This is sometimes necessary to make some of the ActiveX controls work. For example, if you insert ActiveX form fields such as text boxes, drop-down menus, and pushbuttons on your page, the script tells the browser what to do after the user pushes the button on the page.
As with any other element that you can download from the Internet, you should verify that you have the right to use an ActiveX control. Some of these controls are available as freeware, whereas others are available on a commercial basis. Appendix C, "Directory of Resources," lists some online sources where you can check out many ActiveX controls that are available for preview or for use. Internet Explorer 3.0 also furnishes a lot of information about the Microsoft ActiveX controls, and the following URL on Microsoft's Web site hosts a gallery of ActiveX controls:
http://activex.microsoft.com/
You insert an ActiveX control on your page in one of two ways. You use the following method when an ActiveX control exists on your system. When you encounter a page that contains an ActiveX control, you are given the option to download it. When you do, the controls are installed in your Windows system directory. They're also registered in the system registration database. FrontPage examines your system to see what ActiveX controls you have available and allows you to select one of them from a drop-down list.
To insert an ActiveX control that exists on your system, follow these steps:
NOTE |
When possible, obtain a reference document for the control you are inserting. The reference document should tell you the legal settings for each property, the events that can be implemented when the user clicks a control, and other methods that are particular to the control. |
If you don't have a particular ActiveX control installed on your system but you know its class ID, you can insert it on your page. The class ID is a very long 128-bit string that identifies the name and version number of the ActiveX control that you are inserting. This number is assigned by the creator of the ActiveX control. For example, if you insert the Microsoft Forms 2.0 Tab Strip control, you'll see something that looks like this in the View or Edit HTML window:
classid="clsid:EAE50EB0-4A62-11CE-BED6-00AA00611080"
To insert an ActiveX control that does not exist on your system, follow these steps:
After you select a control, using either of the above methods, you complete the entries in the ActiveX Control Properties dialog box as follows:
TIP |
Try not to make your borders too thick if you elect to use them. In most cases, a border thickness of 1 or 2 pixels is sufficient. |
TIP |
You can size the width and height visually in the layout window of the ActiveX control and then use the Width and Height fields in the ActiveX Control Properties dialog box to fine-tune the settings. |
NOTE |
The code source file you specify here uses the CODEBASE attribute. What this entry does is allow the user to download the ActiveX control if it doesn't already exist on his or her system. If the user doesn't have the ActiveX control installed and you don't specify a value in this field, the user won't be able to view the ActiveX controls on your page. The code source (or CODEBASE entry, in HTML terms) also contains the version number of the control as well. If there is a more recent version of the control at the source URL, it is downloaded to the user's system. This ensures that the most current version of the ActiveX control is used. |
Each time you insert an ActiveX control on your page, FrontPage adds code into your HTML page that is enclosed by an <OBJECT> tag. This tag defines the ActiveX control or controls that you inserted on your page. The code includes the ActiveX control's class ID, the settings you define in the layout section of the ActiveX Control Properties dialog box, and the properties that you set with the Properties table editor or Name/Value Pair dialog box. The properties you set are those indicated by the <PARAM NAME> and <VALUE> tags.
You can view and edit additional parameter names and values in the code as necessary by choosing the View | HTML command in the FrontPage Editor. The code is color coded, displaying HTML tag names in black, attribute names in blue, and attribute values in green. For example, the HTML code for the Microsoft Forms 2.0 Tab Strip ActiveX control was edited to specify a total of 4 tabs (TabsAllocated parameter), and the Items and Names parameter values were changed to Main, Links, Topics, and Help. The code now looks something like this (edited slightly for clarity):
<object id="menutabs" name="menutabs" classid="clsid:EAE50EB0-4A62-11CE-BED6-00AA00611080" align="baseline" border="0" width="533" height="313"> <param name="ListIndex" value="0"> <param name="ForeColor" value="4210816"> <param name="Size" value="14111;8290"> <param name="Items" value="Main;Links;Topics;Help;"> <param name="TabOrientation" value="2"> <param name="MultiRow" value="-1"> <param name="TipStrings" value=";;;;"> <param name="Names" value="Main;Links;Topics;Help;"> <param name="NewVersion" value="-1"> <param name="TabsAllocated" value="4"> <param name="Tags" value=";;;;"> <param name="TabData" value="4"> <param name="Accelerator" value=";;;;"> <param name="FontName" value="Arial"> <param name="FontEffects" value="1073741825"> <param name="FontCharSet" value="0"> <param name="FontPitchAndFamily" value="2"> <param name="FontWeight" value="700"> <param name="TabState" value="3;3;3;3"> </object>
In Chapter 23, "Java and Plug-Ins," you learned how to add a PowerPoint animation to your page as a Netscape plug-in. The PowerPoint Animation Player also has the capability to display a PowerPoint animation as an ActiveX control. To insert a PowerPoint animation as an ActiveX control, follow these steps:
In some cases, FrontPage generates VBScript or JavaScript for you automatically. For example, when you choose to validate form fields used with the Internet Database Connector files generated by the Database Connector Wizard, FrontPage generates the VBScript or JavaScript code for you and inserts it into your Web page.
You need to configure your Web settings so that FrontPage knows which language to use when it generates these scripts. You can choose your default scripting language from the FrontPage Web Settings dialog box. To specify your default scripting language, follow these steps:
Some ActiveX controls need more than a location on your page and a few lines of text in your HTML code. Some controls, such as form fields, buttons, labels, tab strips, and similar controls that require user input, need additional code that defines what is supposed to happen when the user chooses a control or enters data into it. For this, you need to write a script.
FrontPage allows you to develop VBScript and JavaScript for your
pages in a couple of ways. VBScript is a subset of Microsoft's
Visual Basic programming language. VBScript code is contained
within your Web page and can be read by Microsoft Internet Explorer
3.0 and other browsers. JavaScript is a subset of the Java scripting
language and also can appear within a Web page. You implement
either of these scripting languages by using dialog boxes or by
using the Script Wizard to author your scripts.
NOTE |
The intent here isn't to show you how to write a complete script using JavaScript or VBScript, because that can get quite involved. This chapter shows you how to use the Script Wizard or the Script dialog box to enter the scripts into your pages. It will help if you have a knowledge of the JavaScript or VBScript programming language. For additional reference on these programming languages, check out the books mentioned in the section "Workshop Wrap-Up," later in this chapter. |
When you insert a script on your page, you choose whether you want to use JavaScript or VBScript. You cannot use both languages on the same page.
An inline script is embedded in the page and runs when the page is displayed in a browser. If you're familiar with either scripting language, you can insert a script into your page with the Script dialog box as follows:
NOTE |
The Run Script on Server option in the Script dialog box was not supported in the Beta 2 release of FrontPage 97. The Other option is provided to support future scripting languages. |
When you use the List view in the Script Wizard, you can only write event scripts. The interface allows you to select objects and associated events. Next, you pick an action that is done when the event takes place. The Script Wizard generates the JavaScript for you automatically.
When you first open the Script Wizard, you see a screen similar
to that shown in Figure 24.8. You use the Script Wizard's List
view to write event scripts. Event scripts perform actions when
a user selects a control on your page.
Figure 24.8 : Use the List view in the Script Wizard to generate event scripts.
You see three panes in the Script Wizard's List view. The first pane is labeled "1. Select an Event." This is the Event pane. You see a hierarchical view of the events that are available to choose from, including the events that are applicable to the ActiveX controls that are inserted on your page.
The first thing you want to do in the Script Wizard is select an event handler. You can't go anywhere else without doing that.
To select an event handler, follow these steps:
After you select an event handler, a couple of things occur. The Script pane waits for you to select an action for the event. In this case, the Script Wizard is waiting for you to select an action to occur when the user clicks the menutabs control, as indicated by the prompt "3. On menutabs Click Perform the following Actions." In addition, the Insert Action button located at the bottom of the Script Wizard enables.
Well, it was easy enough to get that far. The next thing you do is insert an action that takes place when the user selects the option, and that's where it gets interesting (and where you need some additional references). You choose an action from the action pane, labeled "2. Insert Actions." The actions listed in this pane are specific to the ActiveX controls included on your page.
You select an action to perform from the Action pane. The list of actions varies, depending on the control you are using. To give you a simple example of how to insert an action, I'll show you the Go To Page action. This action takes the user to another page or property in your script. You can also use this action to play a sound file when the user clicks a button.
To insert a Go To Page event, follow these steps:
If your script uses global variables, you can add them to your script using the Global Variables selection in the Action pane. When you insert a global variable, the Script Wizard places it at the beginning of the HTML code for the script. In VBScript, a global variable uses the form dim variablename. In JavaScript, global variables use the form var variablename.
To insert a new global variable, follow these steps:
To edit a global variable, follow these steps:
To delete a global variable, follow these steps:
To define a new procedure in your script, select the Procedure option in the Action pane. Procedures are added at the beginning of your script. In VBScript, procedures use the form sub Proceduren(). In JavaScript, procedures use the form function Proceduren().
To insert a new procedure, follow these steps:
You can use the Code view in the Script Wizard to edit your code manually. To switch the Script Wizard to Code view, select the Code View radio button at the bottom of the Script Wizard screen. You can add events and actions to your script by double-clicking items in the Action pane. Then, you can edit the script for the action in the script pane at the bottom of the Script Wizard screen.
In this chapter, you learned how to add ActiveX controls to your pages. You also learned the basics of how to use the Script Wizard to write event code for the controls you place on your pages. Admittedly, further reference is required for this chapter. Coding in JavaScript and VBScript requires knowledge that is beyond the scope of this book and is better covered by books that focus on each topic. However, using either of these scripting languages, you can extend the functionality of your Web pages with customized menus, active multimedia content, and more. Through the use of these Web technologies, you can create pages like the big guys do.
To begin your adventures with JavaScript and VBScript, check out the following books, published by Sams.net:
Laura Lemay's Web Workshop: JavaScript, Laura Lemay and Michael Moncur. ISBN: 1-57521-141-6.
JavaScript Unleashed, Richard Wagner et al. ISBN: 1-57521-118-1.
Teach Yourself JavaScript in 21 Days, Arman Danesh. ISBN: 1-57521-073-8.
Teach Yourself VBScript in 21 Days, Keith Brophy and Timothy Koets.
ISBN: 1-57521-120-3.
Q: | Are there any other online development tools available for ActiveX controls? |
A: | The ActiveX Control Pad, which is available from Microsoft's Web site, contains control references for many of Microsoft's ActiveX controls. In addition to using many of the same features and the Script Wizard
mentioned in this chapter, it also includes the HTML Layout Control, which allows you to layer controls and images on your pages. You can download the ActiveX Control Pad from the following URL: http://www.microsoft.com/workshop/author/cpad/ |
Q: | Are there any other online resources available where I can learn more about the ActiveX controls that are available? |
A: | Additional references are listed in Appendix C, "Directory of Resources." |