There was a recent question on Experts-Exchange asking for help to fade a table, so I wrote up a quick little script, and figured I’d throw it out there in case it might help anyone else.
fade = {
speed : 5,
finalOpacity : 30,
currentOpacity : 100,
elID : null,
init : function(el) {
fade.elID = el;
if (!document.getElementById(el)) return;
fadeInterval = setInterval(’fade.doFade()’,fade.speed);
},
doFade : function(obj) {
obj = document.getElementById(fade.elID);
if (fade.currentOpacity>fade.finalOpacity) {
var newOpacity = fade.currentOpacity - 1;
obj.style.opacity = “.”+(newOpacity);
obj.style.filter = “alpha(opacity=”+newOpacity+”)”;
fade.currentOpacity = newOpacity;
} else {
clearInterval(fadeInterval);
}
}
}
Just call fade.init and pass it the ID of the element you want to fade!