This script is used to highlight a table cell and optionally, the row which contains it.
Place the following code in a custom header:
<script type="text/javascript">
//---------------- Begin User Settings -------------------------------
var cellColor = "#cccccc"; // This sets the cell color
var rowColor = "aqua"; // This sets the row color
var useRows = true; // This determines if rows are highlighted
//---------------- End User Settings ---------------------------------
var origColor;
function markCells(tableObj) {
var div = document.getElementById('O'+tableObj)
var tbl = div.getElementsByTagName("table");
var trs = tbl[0].getElementsByTagName("tr");
for (var i=0; i<trs.length; i++) {
tds = trs[i].getElementsByTagName("td");
for (j=0; j<tds.length; j++) {
tds[j].onmouseover = hiliteCell;
tds[j].onmouseout = retCell;
}
}
}
function hiliteCell() {
origColor = this.style.backgroundColor;
if (useRows) {
this.parentNode.style.backgroundColor = rowColor;
}
this.style.backgroundColor= cellColor;
}
function retCell() {
this.style.backgroundColor= origColor;
if (useRows) {
this.parentNode.style.backgroundColor = origColor;
}
}
</script>There are three user defined variables used in the script:
| cellColor | This defines the background color applied to the table cell when the mouse passes over it. The value is an HTML 6-digit hex color code, or a known color name |
| rowColor | This defines the background color applied to the row containing the table cell when the mouse passes over it. The value is an HTML 6-digit hex color code, or a known color name |
| useRow | This determines if rows are to be highlighted. If the value is set to true, the row will be highlighted along with the cell. If set to false, only the table cell is highlighted |
The following rules are applied when the script is used:
- If a cell object already has a background color, it will not be altered by the script. When you use the SiteSpinner shading tool to give your object a background color, it overrides any background setting given to the table cell.
- If the cell is given a background color, the script will retain the original color when the mouse enters the cell, and return the cell to its normal color when the mouse leaves the cell.
- If row highlighting is enabled, the highlight color will only appear in cells that contain no background color
Contact the LowTechGeezer
VM User's Forum
Bruceee's Sandpit
Webmaster's Corner
Other Useful Sites