| 类别: |
Javascript, function
|
| 标签: |
highlight, js, func, fSetAlternativeColor
|
| 摘要: |
..
|
| 正文: |
- function fSetAlternativeColor(sId, sSubTag, sBgColor1, sBgColor2, sBgMoveColor, bByNode)
- {// shawl.qiu script
- var Obj = null;
- if(typeof(sId)=="string")
- {
- Obj = document.getElementById(sId);
- }
- if(Obj==null)
- {
- alert("主域为 null!");
- return;
- }
- if(!sBgColor1) sBgColor1 = "white";
- if(!sBgColor2) sBgColor2 = "#fcfcfc";
- if(!sBgMoveColor) sBgMoveColor = "whitesmoke";
-
- var Debug = false;
-
- var ChildSet = null;
- if(bByNode)
- {
- ChildSet = Obj.childNodes;
- }
- else
- {
- ChildSet = Obj.getElementsByTagName(sSubTag);
- }
-
- var iCount = 0;
- var iLen = ChildSet.length;
- var iNodeCount = 1;
-
- if(Debug)
- {
- alert(ChildSet);
- alert
- (
- ""
- +"\n ChildSet.length: "+ChildSet.length
- +"\n iCount: "+iCount
- +"\n iNodeCount: "+iNodeCount
-
- );
- }
- while(iCount<iLen)
- {
- if(ChildSet[iCount].nodeType==1&&ChildSet[iCount].nodeName==(sSubTag.toUpperCase()))
- {
- if(iNodeCount%2==0)
- {
- ChildSet[iCount].style.backgroundColor = sBgColor1;
- ChildSet[iCount]["OldColor"] = sBgColor1;
- }
- else
- {
- ChildSet[iCount].style.backgroundColor = sBgColor2;
- ChildSet[iCount]["OldColor"] = sBgColor2;
- } // end if 1
-
- ChildSet[iCount].onmouseover =
- function()
- {
- this.style.backgroundColor = sBgMoveColor;
- }
-
- ChildSet[iCount].onmouseout =
- function()
- {
- this.style.backgroundColor = this["OldColor"];
- }
-
- iNodeCount++;
- } // ne if
- iCount++;
- } // end while
-
- } // 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
|