文字一边渐变色一边切换的js特效

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>文字一边渐变色一边切换的js特效丨石家庄自动门|石家庄地毯</TITLE>
    </HEAD>
    <body bgcolor="#ffffff" onLoad="fade()">
    <span id="fader">
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    var texts = new Array(
    "<font size=‘+2‘ color=‘{COLOR}‘ face=‘Arial‘><strong>523</strong></font>",
    "<font size=‘+3‘ color=‘{COLOR}‘ face=‘Arial‘><strong>786</strong></font>",
    "<font size=‘+4‘ color=‘{COLOR}‘ face=‘Arial‘><strong>4322</strong></font>",
    "<font size=‘+3‘ color=‘{COLOR}‘ face=‘Arial‘><strong>123~</font>",
    "<a href=‘http://www.CsrCode.cn‘ target=‘_top‘><font size=‘+3‘ color=‘{COLOR}‘ face=‘Arial‘><strong>Welcome~!!</strong></font></a>");
    var bgcolor = "#000000"; // background color, must be valid browser hex color (not color names)
    var fcolor = "#FF8000";  // foreground or font color
    var steps = 20; // number of steps to fade
    var show = 500; // milliseconds to display message
    var sleep = 30; // milliseconds to pause inbetween messages
    var loop = true; // true = continue to display messages, false = stop at last message
    var colors = new Array(steps);
    getFadeColors(bgcolor,fcolor,colors);
    var color = 0;
    var text = 0;
    var step = 1;
    function fade() {
    var text_out = texts[text].replace("{COLOR}", colors[color]); // texts should be defined in user script, e.g.: var texts = new Array("<font color=‘{COLOR}‘ sized=‘+3‘ face=‘Arial‘>howdy</font>");
    if (document.all) fader.innerHTML = text_out; // document.all = IE only
    if (document.layers) { document.fader.document.write(text_out); document.fader.document.close(); } // document.layers = Netscape only
    color += step;
    if (color >= colors.length-1) {
    step = -1; // traverse colors array backward to fade out
    if (!loop && text >= texts.length-1) return;
    }
    if (color == 0) {
    step = 1;
    text += 1;
    if (text == texts.length) text = 0; // loop back to first message
    }
    setTimeout("fade()", (color == colors.length-2 && step == -1) ? show : ((color == 1 && step == 1) ? sleep : 50)); // sleep and show should be defined in user script, e.g.: var sleep=30; var show=500;
    }
    function getFadeColors(ColorA, ColorB, Colors) {
    len = Colors.length;
    if (ColorA.charAt(0)==#) ColorA = ColorA.substring(1);
    if (ColorB.charAt(0)==#) ColorB = ColorB.substring(1);
    var r = HexToInt(ColorA.substring(0,2));
    var g = HexToInt(ColorA.substring(2,4));
    var b = HexToInt(ColorA.substring(4,6));
    var r2 = HexToInt(ColorB.substring(0,2));
    var g2 = HexToInt(ColorB.substring(2,4));
    var b2 = HexToInt(ColorB.substring(4,6));
    var rStep = Math.round((r2 - r) / len);
    var gStep = Math.round((g2 - g) / len);
    var bStep = Math.round((b2 - b) / len);
    for (i = 0; i < len-1; i++) {
    Colors[i] = "#" + IntToHex(r) + IntToHex(g) + IntToHex(b);
    r += rStep;
    g += gStep;
    b += bStep;
    }
    Colors[len-1] = ColorB;
    }
    function IntToHex(n) {
    var result = n.toString(16);
    if (result.length==1) result = "0"+result;
    return result;
    }
    function HexToInt(hex) {
    return parseInt(hex, 16);
    }
    //  End -->
    </script></span>
    </BODY>
    </HTML>
    <br><br><hr>
    

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。