コメント |
http://samples.msdn.microsoft.com/workshop/samples/components/htc/refs/addBehavior.htm
@DIV
<SCRIPT>
var collBehaviorID = new Array();
var collLI = new Array ();
var countLI = 0;
function attachBehavior()
{
collLI = document.all.tags ("LI");
countLI = collLI.length;
for (i=0; i < countLI; i++)
{
var iID = collLI[i].addBehavior ("hilite.htc");
if (iID)
collBehaviorID[i] = iID
}
}
function detachBehavior()
{
for (i=0; i < countLI; i++)
collLI[i].removeBehavior (collBehaviorID [i]);
}
</SCRIPT>
@END
[[hilite.htc]]
@DIV
<PUBLIC:COMPONENT>
<PUBLIC:ATTACH EVENT="ondetach" ONEVENT="cleanup()" />
<SCRIPT LANGUAGE="JScript">
var normalColor;
attachEvent ('onmouseover', Hilite);
attachEvent ('onmouseout', Restore);
function cleanup()
{
window.status = 'ondetach event fired';
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>
</PUBLIC:COMPONENT>
@END
|