crmpicco
04-14-2005, 02:47 PM
http://www.clagnut.com/sandbox/imagefades/
function setOpacity(obj, opacity) {
opacity = (opacity == 100)?99.999:opacity;
// IE/Win
obj.style.filter = "alpha(opacity:"+opacity+")";
// Safari<1.2, Konqueror
obj.style.KHTMLOpacity = opacity/100;
// Older Mozilla and Firefox
obj.style.MozOpacity = opacity/100;
// Safari 1.2, newer Firefox and Mozilla, CSS3
obj.style.opacity = opacity/100;
}
function fadeIn(objId,opacity) {
if (document.getElementById) {
obj = document.getElementById(objId);
if (opacity <= 100) {
setOpacity(obj, opacity);
opacity += 75; // the level of darkness (100 - high, 0 - low)
window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
}
}
}
function initImage() {
imageId = 'thephoto';
image = document.getElementById(imageId);
setOpacity(image, 0);
image.style.visibility = 'visible';
fadeIn(imageId,0);
}
window.onload = function() {initImage()}
document.write("<style type='text/css'>#thephoto {visibility:hidden;} </style>");
Can anyone see a way to speed up the change from my original image to the white image?
The opacity?
function setOpacity(obj, opacity) {
opacity = (opacity == 100)?99.999:opacity;
// IE/Win
obj.style.filter = "alpha(opacity:"+opacity+")";
// Safari<1.2, Konqueror
obj.style.KHTMLOpacity = opacity/100;
// Older Mozilla and Firefox
obj.style.MozOpacity = opacity/100;
// Safari 1.2, newer Firefox and Mozilla, CSS3
obj.style.opacity = opacity/100;
}
function fadeIn(objId,opacity) {
if (document.getElementById) {
obj = document.getElementById(objId);
if (opacity <= 100) {
setOpacity(obj, opacity);
opacity += 75; // the level of darkness (100 - high, 0 - low)
window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
}
}
}
function initImage() {
imageId = 'thephoto';
image = document.getElementById(imageId);
setOpacity(image, 0);
image.style.visibility = 'visible';
fadeIn(imageId,0);
}
window.onload = function() {initImage()}
document.write("<style type='text/css'>#thephoto {visibility:hidden;} </style>");
Can anyone see a way to speed up the change from my original image to the white image?
The opacity?