PDA

View Full Version : Make some text appear gradually...


Grand Mamamouch
09-23-2004, 05:55 AM
Hi !

I'd like to make some texte appear gradually.

I found the name of the background and the text colors and great! thanx to someone of you, the name of the function that
translate decimals into hexadecimals.

For now, i don't work on the duration questions.

Here is where i am :

<div
id = texte
>
tbtuf6ny7idntyutbtuf6ny7idntyutbtuf6ny
</div>

<script language = 'Javascript'>

hd_bg = document.bgColor.replace('#', '0x')
hd_text = document.fgColor.replace('#', '0x')
current = hd_bg

delai = 22

function make_appear()
{
if( current < hd_text )
current++
else if( current > hd_text )
current--
else
alert('Fini!')

hd_current = current.toString(16)

document.getElementById('texte').innerHTML = " <a style = ' color : #" + hd_current + " ' > aaaaaaaaaaaaa </a> "

setTimeout(make_appear(), delai)
}

make_appear()

</script>

Problemes :

1. The alert window never comes out.

2. The coloring stops at yellow while the text beginning color is black.

Thanx for the hand !

Dominique

hemebond
09-23-2004, 07:08 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Javascript Fade-in</title>
<script type="text/javascript">
var current_opacity = 0.0;

function fade()
{
document.getElementById("fade").style.MozOpacity = current_opacity;
current_opacity += 0.1;

if(current_opacity < 1.0)
{
setTimeout("fade()",500);
}
}
window.onload = fade;
</script>
</head>
<body>
<p id="fade">
<a href="">This is a text link that with fade into view</a>
</p>
</body>
</html>Works only in Gecko browsers. Tried some things to get it to work in Internet Explorer but even using its proprietry extensions it didn't work.

Willy Duitt
09-23-2004, 08:31 AM
never (http://www.webdeveloper.com/forum/showthread.php?s=&threadid=45057) never (http://www.sitepoint.com/forums/showthread.php?t=197507) mind......