Microsoft HomeproductssearchsupportshopWrite Us   Microsoft Home
Magazine
 |  Community
 |  Workshop
 |  Tools & Samples
 |  Training
 |  Site Info

Workshop  |  Component Development

Defining Custom Events


You can use custom events to:

As with standard events, you must send the event from the scriptlet and capture the event in the host application.

To send a custom event in the scriptlet:

For example, the following shows how you can send a custom event called oncolorchange whenever the scriptlet's backgroundColor property is reset.

<SCRIPT LANGUAGE="JavaScript">
function public_put_backgroundColor(value)
{
   window.document.bgColor = value;
   window.external.raiseEvent("event_onbgcolorchange",window.document);
}
</SCRIPT>

To handle a custom event in the host application:

The following is an example in Microsoft® Visual Basic® that shows how you can determine which control triggered an event.

Sub ScriptletContainer1_onscriptletevent( ByVal txtTitle As String, _
ByVal eventData As Variant) objName = eventData.srcElement.ID MsgBox "The event " & txtTitle & " occurred in " & objName End Sub

If your host application is Microsoft Internet Explorer, use a script such as the following to capture the scriptlet event.

<SCRIPT   LANGUAGE="JavaScript" 
FOR=ScriptletControl1
EVENT= onscriptletevent (name, eventData)> alert("The event that occurred in the scriptlet was " + name); </SCRIPT>

You can use a Select Case structure in the onscriptletevent event to take different actions based on different events.

See Also

Handling Standard Events


Does this content meet your programming needs? Write us!

Back to topBack to top

© 1998 Microsoft Corporation. All rights reserved. Terms of use.

 

Magazine Home
Ask Jane
DHTML Dude
Extreme XML
For Starters
More or Hess
Servin' It Up
Site Lights
Web Men Talking
Member Community Home
Benefits: Freebies & Discounts
Benefits: Promote Your Site
Benefits: Connect with Your Peers
Benefits at a Glance
Online Special-Interest Groups
Your Membership
SBN Stores
Join Now
Workshop Home
Essentials
Content & Component Delivery
Component Development
Data Access & Databases
Design
DHTML, HTML & CSS
Extensible Markup Language (XML)
Languages & Development Tools
Messaging & Collaboration
Networking, Protocols & Data Formats
Reusing Browser Technology
Security & Cryptography
Server Technologies
Streaming & Interactive Media
Web Content Management
Workshop Index
Tools & Samples Home
Tools
Samples, Headers, Libs
Images
Sounds
Style Sheets
Web Fonts
Training Home
SBN Live Seminars
SBN Live Chats
Courses
Peer Support
CD-ROM Training
Books & Training Kits
Certification
SBN Home
New to SBN?
What's New on SBN
Site Map
Site Search
Glossary
Write Us
About This Site