Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help for text fader!

Status
Not open for further replies.

kippie

Technical User
Nov 8, 2001
158
I have a HTML to fade in different texts independent of each other. In the HTML below there are 2 texts fading in, the first one second after loading and the second, 2 seconds after loading. Text1 fades in nicely, but text2 doesn't seem to fade in at all. It just appears in a fraction of a second. And I don't know why. It seems the fadein of text1 and text2 somehow interfere with each other. Can anyone help?

<html>
<head>
</head>
<body>
<div id=&quot;divtofade&quot; style=&quot;filter:alpha(opacity=0); width:250;&quot;>
<h1>text1</h1>
</div>
<div id=&quot;divtofade2&quot; style=&quot;filter:alpha(opacity=0); width:250;&quot;>
<h1>text2</h1>
</div>
<script language=&quot;JavaScript&quot;>
function doFadeIn(fadeName,maxPct)
{
var fadeObj = document.getElementById(fadeName)
if (fadeObj.filters.alpha.opacity < maxPct)
{
fadeObj.filters.alpha.opacity=divtofade.filters.alpha.opacity+4
setTimeout(&quot;doFadeIn('&quot; + fadeObj.id + &quot;',&quot; + maxPct + &quot;)&quot;,50)
}
}
setTimeout(&quot;doFadeIn('divtofade',100)&quot;,1000)
setTimeout(&quot;doFadeIn('divtofade2',100)&quot;,2000)
</script>
</body>
</html>

Kippie
 
It may be that you are using the same timeout for each fade.
You can specify different 'threads' fro timeout by setting them to vars.

var t1 = setTimeout(&quot;doFadeIn('divtofade',100)&quot;,1000)
var t2 = setTimeout(&quot;doFadeIn('divtofade2',100)&quot;,2000)


Then you can clear them independantly also.

window.clearTimeout(t1);

<bb/>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top