JavaScript Reference/Javascript Methods/removeBehavior
"removeBehavior()" Example
<!--
Example revised from
The Web Programmer"s Desk Reference
by Lazaro Issi Cohen and Joseph Issi Cohen
ISBN: 1593270119
Publisher: No Starch Press 2004
-->
<html>
<body>
<script language="JavaScript">
var behaviorID
function commandAdd() {
behaviorID = document.all.myDiv.addBehavior("makered.htc");
}
function commandRemove() {
document.all.myDiv.removeBehavior(behaviorID);
}
</script>
<button onclick="commandAdd();">Add behavior</button>
<button onclick="commandRemove();">Remove behavior</button>
<div id="myDiv" style="border:solid; width:500; height:200;">This is a div</div>
</body>
</html>
<!--
Contents of makeRed.htc:
<public:attach event="onmouseover" onevent="turnRed()" />
<public:attach event="onmouseout" onevent="turnNormal()" />
<public:property name="redColor" />
<public:method name="setRedColor" />
<script language="JavaScript">
var black
var redColor = "red"
function setRedColor(color) {
redColor = color
}
function turnRed() {
if (event.srcElement == element) {
black = style.color
runtimeStyle.color = redColor
}
}
function turnNormal() {
if (event.srcElement == element) {
runtimeStyle.color = black
}
}
</script>
-->
"removeBehavior()" is applied to
+----------------+--------------------------------------------------------------+
| Applied_To |<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> |
| |<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> |
| |<isindex> <kbd> |
| |<label> <legend> |
| |<li> <link> |
| |<listing> <map> |
| |<marquee> <menu> |
| |<nobr> <noframes> |
| |<noscript> <object> |
| |<ol> <option> |
| |<p> <plaintext> |
| |<pre> <q> |
| |<rt> <ruby> |
| |<s> <samp> |
| |<script> <select> |
| |<small> <span> |
| |<strike> <strong> |
| |<style> <sub> |
| |<sup> <table> |
| |<tbody> <td> |
| |<textarea> <tfoot> |
| |<th> <thead> |
| |<title> <tr> |
| |<tt> <u> |
| |<ul> <var> |
| |<wbr> <xml> |
| |<xmp> |
+----------------+--------------------------------------------------------------+
"removeBehavior()" Syntax, Parameters and Note
Note:
Removes a behavior from the element.
Returns true (successful) or false (failed).
Syntax:
document.all.elementID.removeBehavior(param1)
Parameters:
param1 Required; the behavior identifier.