Fade in object cript

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

Categories
- 35.9K All Categories
- 109 ✫ Announcements
- 33.1K Lectora®
- 31.1K Lectora Discussions
- 29K Lectora Desktop
- 2K Lectora Online
- 2K Lectora Feature Requests
- 71 Lectora User Groups
- 36 Lectora Accessibility User Group (LAUG)
- 25 ELB Learning Content
- 25 ELB Learning Content Discussions
- 328 CenarioVR®
- 195 CenarioVR Discussions
- 133 CenarioVR Feature Requests
- 42 Rockstar Learning Platform®
- 39 Rockstar Learning Platform Discussions
- 108 CourseMill®
- 108 CourseMill Discussions
- 47 ReviewLink®
- 47 ReviewLink Discussions
- 7 The Training Arcade®
- 7 The Training Arcade Discussions
- 936 All Things eLearning
- 37 eLearning Development
- 546 Learning Management System (LMS) Integration
- 333 Web Accessibility
- 1.2K ♪ The Green Room
- 9 Additional Learning Products