Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1305 How can I fade in and out the color of text in a layer in Netscape Navigator 4 and Internet Explorer 4+?

You are here: irt.org | FAQ | JavaScript | DHTML | Q1305 [ previous next ]

Try:

<script language="JavaScript"><!--
function fader(object,text) {
    setTimeout("fade('" + object + "','" + text + "','#000000')",100);
    setTimeout("fade('" + object + "','" + text + "','#330000')",200);
    setTimeout("fade('" + object + "','" + text + "','#660000')",300);
    setTimeout("fade('" + object + "','" + text + "','#990000')",400);
    setTimeout("fade('" + object + "','" + text + "','#cc0000')",500);
    setTimeout("fade('" + object + "','" + text + "','#ff0000')",600);
    setTimeout("fade('" + object + "','" + text + "','#ff0000')",700);
    setTimeout("fade('" + object + "','" + text + "','#cc0000')",800);
    setTimeout("fade('" + object + "','" + text + "','#990000')",900);
    setTimeout("fade('" + object + "','" + text + "','#660000')",1000);
    setTimeout("fade('" + object + "','" + text + "','#330000')",1100);
    setTimeout("fade('" + object + "','" + text + "','#000000')",1200);
}

function fade(object,text,color) {
    if (document.layers) {
        document.layers[object].document.open();
        document.layers[object].document.write('<font color="' + color + '">' + text + '<\/font>');
        document.layers[object].document.close();
    }
    else if (document.all) {
        document.all[object].style.color = color;
    }
}
//--></script>

<form>
<input type="button" value="Click me" onClick="fader('myLayer1','This is some text')">
</form>

<div id="myLayer1" style="position:absolute">
This is some text
</div>

©2018 Martin Webb