detachEvent Method
Unbinds the specified function from the event, so that the function stops receiving notifications when the event fires on the object.
Syntax
object.detachEvent (sEvent, fpNotify)
Parameters
sEvent Required. String that specifies any of the standard DHTML events. fpNotify Required. Pointer that specifies the function previously set using the attachEvent method.
Return Value
No return value.
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 ATTACH element automatically stop receiving notifications when the behavior detaches from the element, and thus do not need to call the detachEvent method.
Example
This example calls the detachEvent method from an HTML Component (HTC) when the highlighting effect is removed from the page, causing the ondetach event to fire.
Sample Code
<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>
Applies To
[ Object Name ] Platform Version Win16: Win32: Mac: Unix: WinCE: Version data is listed when the mouse hovers over a link, or the link has focus. A, 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, 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
See Also
attachEvent, dhtml behaviors, using dhtml behaviors, implementing dhtml behaviors in script
Did you find this topic useful? Suggestions for other topics? write us!
© 1999 microsoft corporation. all rights reserved. terms of use.