ソース掲示板




すべてから検索

キーワード   条件 表示 現行ログ 過去ログ トピックス 名前 本文
Microsoft の addBehavior のサンプル
日時: 2008/05/29 08:59
名前: lightbox



http://samples.msdn.microsoft.com/workshop/samples/components/htc/refs/addBehavior.htm

拡張子:
<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>
hilite.htc
拡張子:
<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>
メンテナンス


日時: 2008/05/29 08:59
名前: lightbox