Fade Text In on Page Load

I learned a neat little HTML/Javascript trick on the about page of the newly launched Orkut from Google.

Here is the trick (let the page load entirely, then watch the next line (on smaller pages it’s much cooler… see the individual story archive page to see it happen the way it should really happen)):

This text will fade in on page load. But this text won’t (It’s displayed in-line as the page is built).

It’s accomplished with code that looks like this:


<html>
<head>
<script language="javascript">
col=255;
function fade() { document.getElementById("fade").style.color="rgb(" + col + "," + col + "," + col + ")"; col-=5; if(col>0) setTimeout('fade()', 10); }
</script>
</head>

<body onLoad="fade()">

<p>
<span id="fade">This text will fade in.</span> But this text won't.
</p>

</body></html>

Pretty cool huh?

(If it doesn’t seem to work for you, it’s probably because this page loads pretty slowly… see the individual archive page for it to look more natural.)

12 Responses to “Fade Text In on Page Load”


Leave a Reply




Bad Behavior has blocked 2123 access attempts in the last 7 days.