<!--
//*************************************************************************************************
// Row mouseover//*************************************************************************************************
var strRowClassName = "";
onload = function() {
var strHighColor = "#FFFF9F"; //MouseOver
var objRow, i, j, objTDs;
if (strRowClassName == "")return;
var objTRs = document.getElementsByTagName("tr"); i = 0;
while (objRow = objTRs.item(i++)) {
if (strRowClassName.indexOf(objRow.className) > 0) {
objRow.onmouseover = function() { 
for (j = 0; j < this.cells.length; j++){
if(this.cells[j].tagName.toLowerCase() != "td")continue;
this.cells[j].style.backgroundColor = strHighColor; 
}
}
objRow.onmouseout = function() { 
for (j = 0; j < this.cells.length; j++){
if(this.cells[j].tagName.toLowerCase() != "td")continue;
this.cells[j].style.backgroundColor = ""; 
}
}
}
}
}
//*************************************************************************************************
// "a" tag mouseover window status//*************************************************************************************************
document.onmousemove = function(){
var myAnchor = window.event.srcElement;
var strInnerText;
if (myAnchor.tagName){
if (myAnchor.tagName.toLowerCase() == "a"){
myAnchor.onfocus = function() {
strInnerText = this.innerText;
window.status = strInnerText; 
return (true);
}
myAnchor.onmouseover = function() {
strInnerText = this.innerText;
window.status = strInnerText; 
return (true);
}
myAnchor.onmouseout = function() {
window.status = ""; 
return (true);
}
}
}
}
//-->它是一个鼠标事件,当鼠标覆盖上去变色,移走变为无色,不知道怎么调用,请大家帮看看,谢谢!

解决方案 »

  1.   

    <!--
    //*************************************************************************************************
    // Row mouseover//*************************************************************************************************
    var strRowClassName = "ktr";    //设置为tr中的样式名称 如果两个tr样式不同
                                     //比如class1,class2 则可以设置为
                                     //strRowClassName = "class1class2";    
    onload = function() {
    var strHighColor = "#0000FF";//MouseOver
    var objRow, i, j, objTDs;
    if (strRowClassName == "") return;
    var objTRs = document.getElementsByTagName("tr");
    i = 0;
    while (objRow = objTRs.item(i++)) {
    if (strRowClassName.indexOf(objRow.className) >= 0) {   //*这边错了,应该改为>=0
    objRow.onmouseover = function() { 
    for (j = 0; j < this.cells.length; j++){
    if(this.cells[j].tagName.toLowerCase() != "td")continue;
    this.cells[j].style.backgroundColor = strHighColor; 
    }
    }
    objRow.onmouseout = function() { 
    for (j = 0; j < this.cells.length; j++){
    if(this.cells[j].tagName.toLowerCase() != "td")continue;
    this.cells[j].style.backgroundColor = ""; 
    }
    }
    }
    }
    }
    //*************************************************************************************************