...
代码块 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
function main(spreadsheetReport) { var elems = spreadsheetReport.elemSheetFrame.contentWindow.document.getElementsByTagName("A"); var oldElem=""; //用于存放上一次点击链接的对象 for (var i = 0; i < elems.length; i++) { var elem = elems[i]; // 设置点击跳转前的字体颜色和下划线 //设置字体颜色 elem.firstChild.style.color = "#ffff00"; //设置下划线颜色 elem.style.color = "#ffff00"; //隐藏下划线 elem.style.textDecoration = "none"; if (elem.firstElementChild) { elem.firstElementChild.style.textDecoration = "none"; } if (elem.parentElement) { elem.parentElement.style.textDecoration = "none"; } // 设置点击跳转后的字体颜色和下划线 elem.onclick = function() { this.firstChild.style.color = "#fff00"; this.style.color = "#0000ff"; //判断上一次点击的是哪个链接,如果上一次有点击,则先将上一次的取消,然后再设置本次点击的背景色,然后再将本次的点击对象作为旧的对象,以便下一次的判断 if(oldElem){ oldElem.style.backgroundColor = ""; this.style.backgroundColor = "#ff0000"; oldElem=this; } //如果上一次没有点击任何链接,本次是第一次点击 else{ this.style.backgroundColor = "#ff0000"; oldElem=this; } // this.style.textDecoration = "none"; }; // 鼠标移入时设置单元格背景色 var c = elem.parentNode; spreadsheetReport.addListener(c, "mouseover", function() { this.style.backgroundColor = "#ff0000"; }, c); // 鼠标离开时设置单元格背景色 spreadsheetReport.addListener(c, "mouseout", function() { this.style.backgroundColor = "#ffffff"; }, c); } } |
...