Hi
I'd like to fade in a div using javascript, some seconds after rest of page has loaded.
This code is a simple fade-in:
HTML Code:
<style>logo{filter:alpha(opacity=0);opacity:0}</style>
<script>
function Logo(){var fade=0,logo=document.getElementById("logo").style,ms=(logo.opacity==0)?0:1,pace=setInterval(Fade,20);function Fade(){if(fade<100){fade+=1;if(ms)logo.filter="alpha(opacity="+fade+")";else logo.opacity=(fade/100)}else clearInterval(pace)}};
window.onload=Logo;
</script>
<body><div id="logo">CONTENT</div></body>
This works in IE (if you specify width of div) and FF. However, it did for somereason give an alert in IE7.
Is there any way I can apply timeout to it so the div only fades in after,say, 10 seconds? I have tried,but without success. I can slow the fade-in effects, but that's not what I would like to happen. What i am hoping for is, say, 10 seconds of nothing, then a fade-in over 1 second.
I don't want to go to the extent of the rather long scripts in Scriptaculous. I did find another nice-looking script at
http://www.brandspankingnew.net/archive/2006/09/javascript_css_crossfader.html
but again, though I can change the speed of fade-in, I can't achieve a timeout to make it start late.
Any ideas please?
Many thanks
Tony
|