js 隔行高亮/鼠标划过高亮 函数 fSetAlternativeColor

类别: Javascript, function
标签: highlight, js, func, fSetAlternativeColor
摘要: ..
正文:
  1.   function fSetAlternativeColor(sId, sSubTag, sBgColor1, sBgColor2, sBgMoveColor, bByNode)
  2.   {// shawl.qiu script
  3.    var Obj = null;
  4.    if(typeof(sId)=="string") 
  5.    {
  6.     Obj = document.getElementById(sId);
  7.    }
  8.    if(Obj==null)
  9.    {
  10.     alert("主域为 null!");
  11.     return;
  12.    }
  13.    if(!sBgColor1) sBgColor1 = "white";
  14.    if(!sBgColor2) sBgColor2 = "#fcfcfc";
  15.    if(!sBgMoveColor) sBgMoveColor = "whitesmoke";
  16.    
  17.    var Debug = false;
  18.  
  19.    var ChildSet = null;
  20.    if(bByNode)
  21.    {
  22.     ChildSet = Obj.childNodes;
  23.    }
  24.    else
  25.    {
  26.     ChildSet = Obj.getElementsByTagName(sSubTag);
  27.    }
  28.    
  29.    var iCount = 0;
  30.    var iLen = ChildSet.length;
  31.    var iNodeCount = 1;
  32.    
  33.    if(Debug)
  34.    {
  35.     alert(ChildSet);
  36.     alert
  37.     (
  38.      ""
  39.      +"\n ChildSet.length: "+ChildSet.length
  40.      +"\n iCount: "+iCount
  41.      +"\n iNodeCount: "+iNodeCount
  42.      
  43.     );
  44.    }
  45.    while(iCount<iLen)
  46.    {
  47.     if(ChildSet[iCount].nodeType==1&&ChildSet[iCount].nodeName==(sSubTag.toUpperCase()))
  48.     {
  49.      if(iNodeCount%2==0)
  50.      {
  51.       ChildSet[iCount].style.backgroundColor = sBgColor1;
  52.       ChildSet[iCount]["OldColor"] = sBgColor1;
  53.      }
  54.      else
  55.      {
  56.       ChildSet[iCount].style.backgroundColor = sBgColor2;
  57.       ChildSet[iCount]["OldColor"] = sBgColor2;
  58.      } // end if 1
  59.      
  60.      ChildSet[iCount].onmouseover =
  61.       function()
  62.       {
  63.        this.style.backgroundColor = sBgMoveColor;
  64.       }
  65.      
  66.      ChildSet[iCount].onmouseout =
  67.       function()
  68.       {
  69.        this.style.backgroundColor = this["OldColor"];
  70.       }
  71.       
  72.      iNodeCount++;
  73.     } // ne if 
  74.     iCount++;
  75.    } // end while
  76.  
  77.   } // end function fSetAlternativeColor
文章相关信息:
主题: js 隔行高亮/鼠标划过高亮 函数 fSetAlternativeColor
发表者: shawl.qiu
电子邮件: shawl.qiu@gmail.com
QQ: 908202921
MSN: btbtd@msn.com
Homepage: http://www.btbtd.org/
Blog: http://blog.csdn.net/btbtd/
发表日期: 2007-6-3 1:53:06
更新日期: 2007-6-3 1:53:06
来源引用: shawl.qiu CSharp DotNet 个人资料管理系统
引用本页: http://gi.2288.org/mod/code/display/Default.aspx?aid=451
关闭
Google
搜索WWW
搜索www.btbtd.org
搜索blog.csdn.net
Powered by shawl.qiu © 2008-2010 the shawl.qiu Javascript Kits
Copyright © 2008-2010 by shawl.qiu