A little while back, K. was asked to change the mouse-over color for links on a client's website. He figured it'd be a pretty easy change: just edit the CSS file and change the :hover class containing the links. Obviously, since I'm talking it about it here, that wasn't the case.

Upon looking at the source code for the site, K. was greeted with this rather unique way of changing link colors, underlines, and a number of other styles. Naturally, this technique was not in any central JavaScript file, but copy-pasted into each page with a few minor tweaks.

var original = true;

function changeUl(id)
{
    if (original)
    {
        if (document.getElementById) document.getElementById(id).style.textDecoration = "underline";
        else if (document.all)       document.all[id].style.textDecoration = "underline";
    }
    else
    {
        if (document.getElementById) document.getElementById(id).style.textDecoration = "none";
        else if (document.all)       document.all[id].style.textDecoration = "none";
    }

    original = !original;
}

//ED: Snipped a bunch of other similar functions

function changeColor(id)
{
    if (original)
    {
        if (document.getElementById) document.getElementById(id).style.color = "990000";
        else if (document.all)       document.all[id].style.color = "990000";
    }
    else
    {
        if (document.getElementById) document.getElementById(id).style.color = "000066";
        else if (document.all)       document.all[id].style.color = "000066";
    }

    original = !original;
}

As an added bonus, the website exhibited some rather odd behavior: if you moved the mouse around too quickly, the style changes would "stick" and "flip" due to the "original" variable. But apparently, this particular issue was not high on the client's list of complaints.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!