You can use scriptlets as you would any control.
To add a scriptlet to a Web page
<OBJECT ID="Scriptlet1"
TYPE="text/x-scriptlet"
DATA="http://myserver/sample.htm">
– or –
Specify a URL using the object's PARAM tag, as in the following example:
<OBJECT ID="Scriptlet1" TYPE="text/x-scriptlet" WIDTH=300 HEIGHT=200> <PARAM NAME="url" VALUE="http://myserver/sample.htm" </OBJECT>
Note If you insert a scriptlet into a Web page using a visual tool such as a toolbox or control insertion dialog box, the resulting object definition might include a CLASSID attribute instead of the TYPE attribute.
To add a scriptlet to a host application
Important If you are adding the scriptlet to a Web page, do not set the url property to the URL of the current page. Doing so causes a recursive call to the page and will cause the browser to stop functioning.
You can add scrollbars if the scriptlet is too small to be displayed within the container object. For details, see scrollbar.
You can also resize the container object from within the scriptlet by using a script to set the DHTML script object's pixelHeight and pixelWidth properties. For example, the following example shows how you can resize the scriptlet container when the scriptlet is first loaded:
<HTML ID="MyPage"> <HEAD> <SCRIPT LANGUAGE="VBScript"> Sub window_onload() MyPage.style.pixelHeight = 300 MyPage.style.pixelWidth = 400 End Sub </SCRIPT> </HEAD>
For example, the following code in a Visual Basic form sets a property and calls a method in the page referenced by the ScriptContainer1 control:
Sub cmdColor_Click() ScriptContainer1.BackgroundColor="red" ScriptContainer1.UpdateText (Text1.Text) End Sub
Note In Visual Basic, you must pass a parameter to a scriptlet method even if the method does not require one, or errors can occur. For example, the following statement passes a placeholder parameter of zero to a scriptlet method that does not require parameters:
ScriptContainer1.ToggleColor (0)
Before getting a scriptlet's properties or calling its methods, you must be sure that the scriptlet has been fully loaded. For details, see the container object's onreadystatechange event and readyState property, and the scriptlet's frozen property.
Handling events that occur in the scriptlet is slightly different than it is for events in other objects. For details, see Defining Event Handlers.
See Also
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.