读书人

javascript使页面上的文字定时消失解

发布时间: 2012-02-15 12:09:44 作者: rapoo

javascript,使页面上的文字定时消失
function claerLabel()
{
var col = new Array();
col[15] = '#000000';
col[14] = '#111111';
col[13] = '#222222';
col[12] = '#333333';
col[11] = '#444444';
col[10] = '#555555';
col[9] = '#666666';
col[8] = '#777777';
col[7] = '#888888';
col[6] = '#999999';
col[5] = '#AAAAAA';
col[4] = '#BBBBBB';
col[3] = '#CCCCCC';
col[2] = '#DDDDDD';
col[1] = '#EEEEEE';
col[0] = '#FFFFFF';
var i = col.length;
var isOut = true;

function over()
{
if (i>=0 && isOut)
{
i--;
document.getElementById("ctl00_ContentPlaceHolder2_lblErrorRefNo").style.color=col[i];
alert(i);
}
else if(i<= col.length && !isOut)
{
i++;
document.getElementById("ctl00_ContentPlaceHolder2_lblErrorRefNo").style.color=col[i];
}
else
{
isOut = !isOut;
}

setTimeout('over()',100);
}
over();
//document.getElementById("ctl00_ContentPlaceHolder2_lblErrorRefNo").innerText = '';
}


大家帮帮看看我写的代码,我想在网页上的提示信息(即,ctl00_ContentPlaceHolder2_lblErrorRefNo得值)渐渐消失,写得这种方法,但是运行时出错,请高人帮忙分析一下

[解决办法]

HTML code
<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title>未命名面</title>    <script type="text/javascript">        var col = new Array();     col[15] = '#000000';          col[14] = '#111111';          col[13] = '#222222';          col[12] = '#333333';          col[11] = '#444444';          col[10] = '#555555';          col[9] =  '#666666';          col[8] =  '#777777';          col[7] =  '#888888';          col[6] =  '#999999';          col[5] =  '#AAAAAA';          col[4] =  '#BBBBBB';          col[3] =  '#CCCCCC';          col[2] =  '#DDDDDD';          col[1] =  '#EEEEEE';          col[0] =  '#FFFFFF';        var i = col.length;     var isOut = true;         function pageLoad()     {        over();    }        function over()    {            if (i>=0 && isOut)        {             i--;             document.getElementById("Text1").style.color=col[i];             //alert(i);         }         else if(i <= 14 && !isOut)         {             i++;             document.getElementById("Text1").style.color=col[i];         }         else         {             isOut = !isOut;         }        setTimeout('over()',100);      }     </script>    </head><body>    <form id="form1" runat="server">    <div>        <asp:ScriptManager ID="ScriptManager1" runat="server" />    </div>        <input id="Text1" type="text" value="中文" />    </form></body></html>
[解决办法]

HTML code
<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title>未命名面</title>    <script type="text/javascript">        var col = new Array();     col[15] = '#000000';          col[14] = '#111111';          col[13] = '#222222';          col[12] = '#333333';          col[11] = '#444444';          col[10] = '#555555';          col[9] =  '#666666';          col[8] =  '#777777';          col[7] =  '#888888';          col[6] =  '#999999';          col[5] =  '#AAAAAA';          col[4] =  '#BBBBBB';          col[3] =  '#CCCCCC';          col[2] =  '#DDDDDD';          col[1] =  '#EEEEEE';          col[0] =  '#FFFFFF';        var i = col.length;     var isOut = true;         var timeout;    function pageLoad()     {        over();    }        function over()    {            if (i>=0 && isOut)        {             i--;             document.getElementById("Text1").style.color=col[i];         } else{            isOut = false;            clearTimeout(timeout);}        timeout = setTimeout('over()',100);      }     </script>    </head><body>    <form id="form1" runat="server">    <div>        <asp:ScriptManager ID="ScriptManager1" runat="server" />    </div>        <input id="Text1" type="text" value="中文" />    </form></body></html> 

读书人网 >asp.net

热点推荐