Property | Description |
Scrollbar | Shows or hides the scrollbar for the scriptlet's site |
SelectableContent |
Enables or disables the ability to select the content and copy it to the clipboard |
Version |
Returns a string identifying the current version of the container object |
Method | Description |
BubbleEvent |
Passes the current event down to the host environment, whether an HTML page or a Visual Basic form |
RaiseEvent |
Fires a custom event for the scriptlet |
SetContextMenu |
Allows you to associate a popup menu with the scriptlet |
Figure 5
ambient.htm
<HTML><BODY>
<SCRIPT language="JScript" for="window" event="onload">
alert("JScript 'window.external.version' returned: \n" + window.external.version);
</SCRIPT>
<SCRIPT language="VBScript" for="window" event="onload">
MsgBox "VBScript 'window.external.version' returned: " + window.external.version
</SCRIPT>
</BODY></HTML>
Figure 7 HotImage
<html id=MyPage>
<head>
<title>HotImage Scriptlet</title>
</head>
<body>
<script language="VBscript" for="window" event="onload">
InitHotImage
</script>
<script language="VBscript" for="image" event="onmouseover">
if mEnabled <> 0 then
DoSetImage mHotImageName
window.external.bubbleEvent
end if
</script>
<script language="VBscript" for="image" event="onmouseout">
if mEnabled <> 0 then
DoSetImage mImageName
window.external.bubbleEvent
end if
</script>
<script language="VBscript" for="image" event="onclick">
window.external.bubbleEvent
</script>
<script language="VBscript">
' Initialize the scriptlet
' -------------------------------------------------------
Sub InitHotImage
document.bgColor = mBkgndColor
End Sub
' Change the image
' The scriptlet document is made of a single
' <img> tag which refers the actual GIF file.
' -------------------------------------------------------
Sub DoSetImage( sImage )
Set coll = document.images
coll.item(0).setAttribute "src", sImage
coll.item(0).setAttribute "alt", mDescription
End Sub
' Set a descriptive text for the image
' -------------------------------------------------------
Sub DoSetText( sDescription )
Set coll = document.images
coll.item(0).setAttribute "alt", sDescription
End Sub
</script>
<script language="JScript">
// declare the object interface
public_description = new CreateHotImage;
var InScriptlet = (typeof(window.external.version) == "string")
// Vars that match properties
/*---------------------------------*/
mImageName = "";
mHotImageName = "";
mEnabled = 1;
mBkgndColor = "#C0C0C0";
mDescription = "";
/*---------------------------------*/
function CreateHotImage() {
// This function defines the scriptlet interface in terms of
// properties, methods, and events.
this.put_Image = put_Image;
this.get_Image = get_Image;
this.put_BackgroundColor = put_BackgroundColor;
this.get_BackgroundColor = get_BackgroundColor;
this.put_Description = put_Description;
this.get_Description = get_Description;
this.put_HotImage = put_HotImage;
this.get_HotImage = get_HotImage;
this.put_Enabled = put_Enabled;
this.get_Enabled = get_Enabled;
}
// This scriptlet has no methods and limits to bubble
// standard events. The following JScript functions
// implement the get/set interface for the properties.
// Note that you can call VBScript code from within a
// JScript routine.
/*---------------------------------------------------
// ENABLED: This property enables the effect
----------------------------------------------------*/
function put_Enabled( bYes ) {
mEnabled = bYes;
return 1;
}
function get_Enabled() {
return mEnabled;
}
/*----------------------------------------------------
// DESCRIPTION: Set the tooltip text for the image
-----------------------------------------------------*/
function put_Description( sText ) {
mDescription = sText;
DoSetText( mDescription );
return 1;
}
function get_Description() {
return mDescription;
}
/*----------------------------------------------------
// BACKGROUNDCOLOR: Set the document bgColor property
-----------------------------------------------------*/
function put_BackgroundColor( color ) {
mBkgndColor = color;
document.bgColor = mBkgndColor;
return 1;
}
function get_BackgroundColor() {
return mBkgndColor;
}
/*----------------------------------------------------
// IMAGE: Set the image for the Normal state
-----------------------------------------------------*/
function put_Image( sImageName ) {
mImageName = sImageName;
DoSetImage(mImageName);
return 1;
}
function get_Image() {
return mImageName;
}
/*----------------------------------------------------
// HOTIMAGE: Set the image for the Hot state
-----------------------------------------------------*/
function put_HotImage( sImageName ) {
mHotImageName = sImageName;
return 1;
}
function get_HotImage() {
return mHotImageName;
}
// Note the body of the scriptlet document: a <img> tag
// with no image or alternate text specified. This means that
// you need to initialize it to see something!
</script>
<img id="image" src="" alt="">
</body>
</html>
Figure 9 HotImage Script Code
<script language="VBScript">
<!--
Sub window_onload()
HotImage1.Image = "mind1.gif"
HotImage1.HotImage = "mind2.gif"
HotImage2.Image = "msj1.gif"
HotImage2.HotImage = "msj2.gif"
HotImage1.Description = "Microsoft Interactive Developer"
HotImage2.Description = "Microsoft Systems Journal"
Check1.Value = 1
end sub
--></script>
<script language="VBScript"
for="HotImage1" event="onclick">
<!--
sCRLF = Chr(13) + Chr(10)
s1 = "Congratulations for your choice!"
s2 = "Your preference goes to "
s = s1 + sCRLF + s2 + HotImage1.Description
MsgBox s, 0, "Choose Magazine"
--></script>
<script language="VBScript">
<!--
origColor1 = ""
origColor2 = ""
Sub BtnBkgnd_Click()
if HotImage1.BackgroundColor <> "gainsboro" then
origColor1 = HotImage1.BackgroundColor
HotImage1.BackgroundColor = "gainsboro"
else
HotImage1.BackgroundColor = origColor1
end if
if HotImage2.BackgroundColor <> "gainsboro" then
origColor2 = HotImage2.BackgroundColor
HotImage2.BackgroundColor = "gainsboro"
else
HotImage2.BackgroundColor = origColor2
end if
end sub
--></script>
<script language="VBScript">
<!--
bOrig = 1
Sub BtnInvert_Click()
if bOrig = 1 then
HotImage1.Image = "msj1.gif"
HotImage1.HotImage = "msj2.gif"
HotImage1.Description = "Microsoft Systems Journal"
HotImage2.Image = "mind1.gif"
HotImage2.HotImage = "mind2.gif"
HotImage2.Description = "Microsoft Interactive Developer"
bOrig = 0
else
HotImage1.Image = "mind1.gif"
HotImage1.HotImage = "mind2.gif"
HotImage1.Description = "Microsoft Interactive Developer"
HotImage2.Image = "msj1.gif"
HotImage2.HotImage = "msj2.gif"
HotImage2.Description = "Microsoft Systems Journal"
bOrig = 1
end if
end sub
--></script>
<script language="VBScript">
<!--
Sub Check1_Change()
HotImage1.Enabled = Check1.Value
HotImage2.Enabled = Check1.Value
end sub
--></script>
Figure 12 MyScriptlet Scriptlet
<html id=MyPage>
<head>
<title>MyScriptlet Scriptlet</title>
</head>
<body>
<script language="VBscript" for="window" event="onload">
InitMyScriptlet
</script>
<script language="VBscript">
' Initialize the control
' -------------------------------------------------------
Sub InitMyScriptlet
window.external.selectableContent = mSelectable
End Sub
</script>
<script language="JScript">
// declare the object interface
public_description = new MyScriptlet;
var InScriptlet = (typeof(window.external.version) == "string")
function CreateMyScriptlet() {
}
</body>
</html>