Connecting Tech Pros Worldwide Forums | Help | Site Map

Fading Text

Freightliner
Guest
 
Posts: n/a
#1: Mar 1 '08
Hi,

this script here displays a fading text message.
I would like to display 3 different messages, let's say "Fading text
1", "Fading text 2", "Fading text 3".

Also, is there a way to make it work under FireFox too?

Thank you very much for help




<SCRIPT LANGUAGE="JavaScript1.2">

ie4 = ((navigator.appVersion.indexOf("MSIE")>0) &&
(parseInt(navigator.appVersion) >= 4));
var cnt = 0, cnt2 = 0, add1 = 3, add2 = 10, timerID;

function show() {
if (ie4) {
cnt += add1;
cnt2 += add2;
delay = 30;
if(cnt2 100) cnt2 = 100;
if(cnt 100) {
cnt = 100;
add1 = -10;
add2 = -3;
delay = 350;
}
if(cnt < 0) cnt = 0;
if(cnt2 < 0) {
cnt2 = 0;
add1 = 3;
add2 = 10;
delay = 200;
}
fader.style.filter = "Alpha(Opacity="+cnt2+",FinishOpacity="+cnt
+",style=2)";
timerID = setTimeout("show()", delay);
}
}
window.onload = show;
</script>

</head>

<body bgcolor="#9B3600">

<center<div id="fader" style="width:480;
Filter:Alpha(Opacity=0,FinishOpacity=0,style=2)">
<h4<font family="Arial, Helvetica" color="#FFFFCC">
FADING TEXT 1
<br><br></font></h4</div</center>


</body>
</html>

Jeremy J Starcher
Guest
 
Posts: n/a
#2: Mar 4 '08

re: Fading Text


On Mon, 03 Mar 2008 10:50:08 -0800, Freightliner wrote:
If you had read the the link I gave you, you'd have been able to discount
this one right off.

Jeremy J Starcher
Guest
 
Posts: n/a
#3: Mar 4 '08

re: Fading Text


On Tue, 04 Mar 2008 19:52:58 +0000, Jeremy J Starcher wrote:
Quote:
* * *
How to improve the script and make it fail gracefully:
>
My first idea would be quick and dirty. Put all of the text into the
DIVs or the SPANs so it is available, then use Javascript to 'extract
them' and fade them back in. Perhaps conditionally inline a style sheet
to set the DIV's to "hidden" when JS is available.
>
Change the array to a list of divs to extract the strings from and re-
fade in.
Figures I would remember something important after I posted.

In addition, pre-check the fade methods. If the message can't be faded
back in, don't get rid of it in the first place. That will handle
browsers that either don't support opacity or are not handled by your
code. (IIRC, Konqueror has its own way of setting opacity, but I don't
have that here at the moment.)
Closed Thread