PDA

View Full Version : Simple text-color changing script wont work correctly...



forumname
01-26-2009, 08:22 PM
This script does 3 things. And when you read it, just know what it does those 3 things 3 times, to try and support more browsers. All 3 sections should do exactly the same stuff.
It works on a list of links, and when you click one link it changes its color to black, makes it underlined, and shows a specific area.

This works fine in FF, and does change the visibility in FF, but not IE.


var previouslayer = 'monday';
var previouselem = 'mon';
var vis = 'visible';
var hid = 'hidden';
var non = 'none';
var und = 'underline';
var blue = '#506EA0';
var black = '#000000';
function show(layerToShow)
{
var elem = layerToShow.substring(0, 3);
if (document.all) //early IE
{
//i dont know what to put here, everything i add breaks it
eval( "document.all." + previouslayer + ".style.visibility = hid");
eval( "document.all." + layerToShow + ".style.visibility = vis");
}
if (document.layers) //other
{
document.layers[previouslayer].visibility = hid;
document.layers[previouselem].textDecoration = non;
document.layers[previouselem].color = blue;
document.layers[layerToShow].visibility = vis;
document.layers[elem].textDecoration = und;
document.layers[elem].textDecoration = black;
}
if (document.getElementById && !document.all)
{
prev = document.getElementById(previouslayer);
prev.style.visibility = hid;
prev2 = document.getElementById(previouselem);
prev2.style.textDecoration = non;
prev2.style.color = blue;

nex = document.getElementById(layerToShow);
nex.style.visibility = vis;
nex2 = document.getElementById(elem);
nex2.style.textDecoration = und;
nex2.style.color = black;

}
previouslayer = layerToShow;
previouselem = elem;
}