Aargh! Каждый разработчик JS здесь, похоже, заразился jqueryitis!
Если вы еще не заражены или все еще хотите выйти из него, вот небольшая функция, выполняющая работу через браузер:)
function appear(elm, i, step, speed){
var t_o;
//initial opacity
i = i || 0;
//opacity increment
step = step || 5;
//time waited between two opacity increments in msec
speed = speed || 50;
t_o = setInterval(function(){
//get opacity in decimals
var opacity = i / 100;
//set the next opacity step
i = i + step;
if(opacity > 1 || opacity < 0){
clearInterval(t_o);
//if 1-opaque or 0-transparent, stop
return;
}
//modern browsers
elm.style.opacity = opacity;
//older IE
elm.style.filter = 'alpha(opacity=' + opacity*100 + ')';
}, speed);
}
Появиться
appear(document.getElementsByTagName('DIV')[0], 0, 5, 40);
Исчезнуть
appear(document.getElementsByTagName('DIV')[0], 100, -5, 40);