Whether you use an ActiveX® control (formerly called an OLE control) or a Java object, Microsoft Visual Basic Scripting Edition and Microsoft® Internet Explorer handle it the same way.

Using Objects

You include an object using the <OBJECT> tags and set its initial property values using <PARAM> tags. If you're a Visual Basic programmer, you'll recognize that using the <PARAM> tags is just like setting initial properties for a control on a form.

For example, the following set of <OBJECT> and <PARAM> tags adds an ActiveX control, called Label, to a page. This code is for illustrative purposes — for your script to work, the control or object you are using has to be installed on the client computer.

 CopyCode imageCopy Code
<OBJECT
   classid="clsid:99B42120-6EC7-11CF-A6C7-00AA00A47DD2"
   id=lblActiveLbl
   width=250
   height=250
   align=left
   hspace=20
   vspace=0
>
<PARAM NAME="Angle" VALUE="90">
<PARAM NAME="Alignment" VALUE="4">
<PARAM NAME="BackStyle" VALUE="0">
<PARAM NAME="Caption" VALUE="A Simple Label">
<PARAM NAME="FontName" VALUE="Verdana, Arial, Helvetica">
<PARAM NAME="FontSize" VALUE="20">
<PARAM NAME="FontBold" VALUE="1">
<PARAM NAME="FrColor" VALUE="0">
</OBJECT>

You can get properties, set properties, and invoke methods just as with any of the form controls. The following code, for example, includes <FORM> controls you can use to manipulate two properties of the Label control:

 CopyCode imageCopy Code
<FORM NAME="LabelControls">
<INPUT TYPE="TEXT" NAME="txtNewText" SIZE=25>
<INPUT TYPE="BUTTON" NAME="cmdChangeIt" VALUE="Change Text">
<INPUT TYPE="BUTTON" NAME="cmdRotate" VALUE="Rotate Label">
</FORM>

With the form defined, an event procedure for the cmdChangeIt button changes the label text:

 CopyCode imageCopy Code
<SCRIPT LANGUAGE="VBScript">
<!--
Sub cmdChangeIt_onClick
   Dim TheForm
   Set TheForm = Document.LabelControls
   lblActiveLbl.Caption = TheForm.txtNewText.Value
End Sub
-->
</SCRIPT>

The code qualifies references to controls and values inside the forms just as in the Simple Validation example.

Several ActiveX controls are available for use with Internet Explorer. You can find information about the properties, methods, events, and class identifiers (CLSID) for several controls on the Microsoft® Web site (http://activex.microsoft.com). You can find more information about the <OBJECT> tag by searching for "OBJECT element" at http://msdn.microsoft.com.

NoteNote

Internet Explorer version 3 and earlier required braces ({}) around the classid attribute and did not conform to the W3C specification. Using braces with Internet Explorer version 4 and later generates a "This page uses an outdated version of the <OBJECT> tag" message.

In Vbsedit, you only need to press F1 to get Help for the keyword under the cursor!


Download Now!



Download   Home  

Copyright © 2001-2024 adersοft