body背景色渐隐渐出

来源:互联网 发布:淘宝一元秒杀网 编辑:程序博客网 时间:2024/04/28 01:00
<html>
    <head>
    </head>
    <body onload="fadeIn(5)">
        
        <script>
            var Color=new Array("#00ff00","#00ee00","#bb00ee","#22dd00","#88dd99","#99bb99");
            function fadeIn(n)
            {
                if(n>=1)
                {
                    document.bgColor=Color[n];
                    n-=1;
                    setTimeout("fadeIn("+n+")",500);
                }else
                {
                    setTimeout("fadeOut(1)",500);
                };
            };
            
            function fadeOut(n)
            {
                if(n<=(Color.length-1))
                {
                    document.bgColor=Color[n];
                    n+=1;
                    setTimeout("fadeOut("+n+")",500);
                }else
                {
                    setTimeout("fadeIn("+(Color.length-1)+")",500);
                };
            };
        </script>
    </body>
</html>
0 0