<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>闪烁文字动画效果</title>
    <style type="text/css">
        .style1
        {
            font-size: xx-large;
            font-weight: bold;
            font-family: 华文新魏;
            color: #000080;
            border-left-color: #ACA899;
            border-right-color: #C0C0C0;
            border-top-color: #ACA899;
            border-bottom-color: #C0C0C0;
            background-color: #FF9900;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <table align="center" style="width: 450px; height: 98px;">
            <tr>
                <td align="center" bgcolor="#FF9900">
                    <span class="style1">闪烁文字动画效果</span><br />
                    <br />
                </td>
            </tr>
            <tr>
                <td align="center" bgcolor="Yellow">
                    <script language="JavaScript">
ShowText="我闪，我闪，我是逐个闪烁文字"; //显示的文字
Color1 = "green"; //文字的颜色
Color2 = "red"; //转换的颜色
FontSize = "5"; //字体大小
SwitchSpeed = 500; //转换速度 (1000 = 1 秒)
m = 0;
if (navigator.appName == "Netscape") 
{
    document.write("<layer id=a visibility=show></layer><br><br><br>");
}
else 
{
    document.write("<div id=a></div>");
}
function ChangeShowTextColor()
{
    if (navigator.appName == "Netscape") //如何为Netscape浏览器
    {
        document.a.document.write("<center><font face=arial size =" + FontSize + "><font color=" + Color1 + ">");
        for (var n = 0; n < ShowText.length; n++)
        {
            if(n == m) 
            {
                document.a.document.write("<font face=arial color=" + Color2 + ">" + ShowText.charAt(m) + "</font>");
            }
            else 
            {
                document.a.document.write(ShowText.charAt(n));
            }
        }
        document.a.document.write('</font></font></center>');
        document.a.document.close();
    }
    if (navigator.appName == "Microsoft Internet Explorer") //如果为IE浏览器
    {
    
        string = "<center><font face=arial size=" + FontSize + "><font color=" + Color1 + ">";
        for (var n = 0; n < ShowText.length; n++) 
        {
            if( n == m) 
            {
                string += "<font face=arial color=" + Color2 + ">" + ShowText.charAt(m) + "</font>";
            }
            else 
            {
                string += ShowText.charAt(n);
            }
        }
        string += "</font></font></center>";
        a.innerHTML = string;
    }
    (m == ShowText.length) ? m=0 : m++;
}
setInterval("ChangeShowTextColor()", SwitchSpeed);//设置函数ChangeShowTextColor()执行所间隔的时间
</script>
</td>
            </tr>

        </table>
    
    </div>
    </form>
</body>
</html>
