当前位置: 代码迷 >> JavaScript >> CSDN下载资源评论时的闪烁是如何实现的
  详细解决方案

CSDN下载资源评论时的闪烁是如何实现的

热度:139   发布时间:2012-02-16 21:30:36.0
CSDN下载资源评论时的闪烁是怎么实现的
CSDN下载资源评论时的闪烁是怎么实现的,我发现提交回复时并没有刷新页面,也就是说它只是把数据异步插入到数据库,然后动态添加一个层,让这个层闪烁,但我不知道怎么让动态添加的层闪烁,
 <script language="javascript" type="text/javascript">
  var colors2 = new Array(18); 
  colors2[0]="#000000";
  colors2[1]="#333300";
  colors2[2]="#665500";
  colors2[3]="#997700";
  colors2[4]="#CC9900";
  colors2[5]="#FFCC00";
  colors2[7]="#000000";
  colors2[8]="#333300";
  colors2[9]="#665500";
  colors2[10]="#997700";
  colors2[11]="#CC9900";
  colors2[12]="#FFCC00";
  colors2[13]="#000000";
  colors2[14]="#333300";
  colors2[15]="#665500";
  colors2[16]="#997700";
  colors2[17]="#CC9900";
  colors2[18]="#FFCC00";
  var i=0;
   
  function FadeText() 
  {
  if(i<18)
  {
  document.getElementById("AddContent").style.visibility = "visible";
  document.getElementById("AddContent").style.backgroundColor = colors2[i];
  i++;
  timerID2 = setTimeout( "FadeText()", 100);
  }
  else
  {
  document.getElementById("AddContent").style.backgroundColor="white";
  }
  }
  function getMsg()
  {
  var content=document.getElementById("txtContent").value;
  var name=document.getElementById("txtName").value;
  var divcontent=document.getElementById("AddContent");
  //divcontent.innerHTML="";
  divcontent.innerHTML+="<div style='width: 100%; height: 30px; background-color: #dcdcff; font-weight: bold; font-size: 12px; color: blue;'>"+name+":发表评论</div>";
  divcontent.innerHTML+="<div style='width: 100%; height: 40px; border-bottom: #66ccff 1px dashed; font-size: 12px;'>"+content+"</div>";
  divcontent.innerHTML+="<div style='width: 100%; height: 30px; background-color: #ccffff; font-weight: bold; font-size: 12px; color: blue;'>"+"时间:</div>";
  FadeText();
  i=0;
  }
  </script>
在getMsg()中我动态添加了一个层,但我不知道如何让这个层在加载时就调用上面的FadeText(),我上面的做法会让一个回复者的所有回复都闪烁,而不是最后一个回复,也就是我不知道怎么找到我在一个层中动态添加的最后一个层,50分献上请求解答.

------解决方案--------------------
由于代码不全,只发个大体思路吧,你可以在每组div间放个span用来区分组

JScript code

function getMsg() 
        { 
            var content=document.getElementById("txtContent").value; 
            var name=document.getElementById("txtName").value; 
            var divcontent=document.getElementById("AddContent"); 
            //divcontent.innerHTML=""; 
            divcontent.innerHTML+=" [color=#FF0000]<span>[/color]<div style='width: 100%; height: 30px; background-color: #dcdcff; font-weight: bold; font-size: 12px; color: blue;'>"+name+":发表评论 </div>"; 
            divcontent.innerHTML+=" <div style='width: 100%; height: 40px; border-bottom: #66ccff 1px dashed; font-size: 12px;'>"+content+" </div>"; 
            divcontent.innerHTML+=" <div style='width: 100%; height: 30px; background-color: #ccffff; font-weight: bold; font-size: 12px; color: blue;'>"+"时间: </div>[color=#FF0000]</span>[/color]"; 
            FadeText(); 
            i=0; 
        } 
  相关解决方案