Fade in object cript

jimbush3
jimbush3 Community Member Posts: 15
After a little fooling around I have some code that will fade in / out an image over any background (tested in IE, firefox, and netscape). Here is the code:function runIn(milli, id){    var speed = Math.round(milli / 100);     var timer = 0;    if ( document.getElementById(id).style.visibility == "hidden" ){        for(i = 0; i <= 100; i++){              setTimeout("changeIn(" + i + ",'" + id + "')",(timer * speed));              timer++;         }     } else {        for(i = 100; i >= 0; i--){              setTimeout("changeIn(" + i + ",'" + id + "')",(timer * speed));              timer++;         }     }}function changeIn(opacity, id) {     var object = document.getElementById(id).style;     object.opacity = (opacity / 100);     object.MozOpacity = (opacity / 100);     object.KhtmlOpacity = (opacity / 100);     object.filter = "alpha(opacity=" + opacity + ")";     if ( object.visibility == "hidden" ) object.visibility = "visible";} //src will be your image name (included as a additional file to the external html object)//id will be whatever you like (make sure it matches in the runIn function call)//change visibility to visible to cause image to fade out instead of in//I added the position style element to let you know you can set the position here, however//if you leave it out it will simply place the image where you place the html object on the pagedocument.write('');setTimeout("runIn(2000, 'logo')", 500);If you have any questions or problems with the script let me know. Also, proofread the script before you use it, posting up here always causes some syntax problems.Edited By: jimbush3 on 2008-3-3 11:3:26