This script works perfectly in IE but not at all in Firefox or Safari. I'm a newborn in the javascript world. I read some other posts and tried using Firebug but that didn't help and I tried the error console and that didn't help me either. Please take pity on my foolish soul. The site where I'm using this code is www.tabbertphoto.com. Any help in any way will be greatly appreciated!

Here is the script:

<script language="javascript" type="text/javascript">
<!--
var content=new Array()
content[0]='<img src="../images/appliances/AP1-STOVE_APPLIANCE.jpg" alt="" height="379" width="500" border="1">'
content[1]='<img src="../images/appliances/AP2-Red_dress-Black_dress_model_001.jpg" alt="" height="375" width="500" border="1">'
content[2]='<img src="../images/appliances/AP3-WALL_STOVE_portfolio.jpg" alt="" height="373" width="500" border="1">'

function changetext(whichcontent){
if (document.all)
descriptions.innerHTML='<font face="Verdana"><small>'+whichcontent+'<font></small>'
}


function reset(){
if (!scriptmenu.contains(event.toElement))
descriptions.innerHTML=temphtml
}
//-->
</script>
<script language="javascript" type="text/javascript">

nereidFadeObjects = new Object();
nereidFadeTimers = new Object();

function nereidFade(object, destOp, rate, delta){
if (!document.all)
return
    if (object != "[object]"){  //do this so I can take a string too
        setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
        return;
    }
        
    clearTimeout(nereidFadeTimers[object.sourceIndex]);
    
    diff = destOp-object.filters.alpha.opacity;
    direction = 1;
    if (object.filters.alpha.opacity > destOp){
        direction = -1;
    }
    delta=Math.min(direction*diff,delta);
    object.filters.alpha.opacity+=direction*delta;

    if (object.filters.alpha.opacity != destOp){
        nereidFadeObjects[object.sourceIndex]=object;
        nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
    }
}

</script>

Hi! This is my version of this function, which works with FireFox:

nereidFadeObjects = new Object();
nereidFadeTimers = new Object();
window.onload=function() {
  var e=document.getElementsByTagName('*')
  for (var i=0,l=e.length;i<l;i++) e[i].sourceIndex=i
}
function nereidFade(object, destOp, rate, delta){
        if (!document.all && !document.getElementsByTagName('*'))
        return
        if (object.toString().indexOf("object") == -1){
                setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
                return;
        }
		try
		{
			//Internet Explorer
			clearTimeout(nereidFadeTimers[object.sourceIndex]);
	        diff = destOp-object.filters.alpha.opacity;
	        direction = 1;
	        if (object.filters.alpha.opacity > destOp){
	                direction = -1;
	        }
	        delta=Math.min(direction*diff,delta);
		
	        object.filters.alpha.opacity+=direction*delta;
	        if (object.filters.alpha.opacity != destOp)
			{
	                nereidFadeObjects[object.sourceIndex]=object;nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
	        }
		}
		catch(e)
		{
			//FireFox
			
			if(destOp>1)
			{
				destOp/=100;
			}
			if(delta>1)
			{
				delta/=100;
			}
			var currOpacity = parseFloat(object.style.MozOpacity);
			clearTimeout(nereidFadeTimers[object.sourceIndex]);
	        diff = destOp-currOpacity;
	        direction = 1;
	        if (currOpacity > destOp){
	                direction = -1;
	        }
	        delta=Math.min(direction*diff,delta);
			
			object.style.MozOpacity=currOpacity+direction*delta;
			if (object.style.MozOpacity != destOp)
			{
				nereidFadeObjects[object.sourceIndex]=object;nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
			}
		}
}

Pay attetnion that you have to change the CSS style of the object because the opacity in IE and FireFox is set different:
style="FILTER: alpha(opacity=0); -moz-opacity: 0; opacity: 0;"

Please do you have the modification of the script above for the google chrome? Thanx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.