detachEvent method
[This documentation is preliminary and is subject to change.]
Unbinds the specified function from the event, so that the function stops receiving notifications when the event fires.
Syntax
object.detachEvent(event, pDisp)Standards information
There are no standards that apply here.
Parameters
- event [in]
-
Type: BSTR
String that specifies any of the standard DHTML Events.
- pDisp [in]
-
Type: IDispatch
Pointer that specifies the function previously set using the attachEvent method.
Return value
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Remarks
Behaviors that attach to events using the attachEvent method must explicitly call the detachEvent method to stop receiving notifications from the page when the ondetach event fires. Behaviors that attach to events using the PUBLIC:ATTACH element automatically stop receiving notifications when the behavior detaches from the element, and thus do not need to call the detachEvent method.
Examples
This example calls the detachEvent method from an HTC when the highlighting effect is removed from the page, causing the ondetach event to fire.
Code example: http://samples.msdn.microsoft.com/workshop/samples/components/htc/refs/ondetach.htm
<PUBLIC:ATTACH EVENT="ondetach" ONEVENT="cleanup()" />
<SCRIPT LANGUAGE="JScript">
attachEvent ('onmouseover', Hilite);
attachEvent ('onmouseout', Restore);
function cleanup()
{
detachEvent ('onmouseover', Hilite);
detachEvent ('onmouseout', Restore);
}
function Hilite()
{
if (event.srcElement == element)
{
normalColor = style.color;
runtimeStyle.color = "red";
runtimeStyle.cursor = "hand";
}
}
function Restore()
{
if (event.srcElement == element)
{
runtimeStyle.color = normalColor;
runtimeStyle.cursor = "";
}
}
</SCRIPT>
See also
- a
- abbr
- acronym
- address
- applet
- area
- b
- base
- baseFont
- bgSound
- big
- blockQuote
- body
- br
- button
- caption
- center
- cite
- code
- col
- colGroup
- comment
- custom
- dd
- del
- dfn
- dir
- div
- dl
- document
- dt
- em
- embed
- fieldSet
- font
- form
- frame
- frameSet
- head
- hn
- hr
- html
- i
- iframe
- img
- input type=button
- input type=checkbox
- input type=file
- input type=hidden
- input type=image
- input type=password
- input type=radio
- input type=reset
- input type=submit
- input type=text
- ins
- kbd
- label
- legend
- li
- link
- listing
- map
- marquee
- menu
- namespace
- noBR
- object
- ol
- option
- p
- plainText
- pre
- q
- s
- samp
- script
- select
- small
- span
- strike
- strong
- sub
- sup
- table
- tBody
- td
- textArea
- tFoot
- th
- tHead
- title
- tr
- tt
- u
- ul
- var
- window
- xmp
- Reference
- attachEvent
- Conceptual
- Introduction to DHTML Behaviors
- Using DHTML Behaviors
- Using HTML Components to Implement DHTML Behaviors in Script
Build date: 3/14/2012