动态拉去的数据

动态拉去的数据:

<ul>
 <li><a href="/info/4377_0.html" target="_blank" tabIndex="-1"><font color="red">教您识别常见网络骗术</font></a></li>
 <li><a href="#" onclick="pgvSendClick({hottag:'KF.SERVICE.INDEX.ANNOUNCE'});window.open('http://b.qq.com','_blank');" tabIndex="-1"><font color="red">企业QQ助你创造无限商机</font></a></li>
    <li><a href="/announce/54840.html" target="_blank" tabIndex="-1"><font color="red"><font color="red">关于部分用户QQ空间flash模块不能正常显示公告</font></font></a></li><li><a href="/announce/55673.html" target="_blank" tabIndex="-1"><font color="red"><font color="red">关于QQ城市达人域名升级公告</font></font></a></li><li><a href="/announce/62885.html" target="_blank" tabIndex="-1"><font color="red">关于用户举报QQ外挂等非法软件的相关说明</font></a></li><li><a href="/announce/62789.html" target="_blank" tabIndex="-1"><font color="red"><font color="red">部分用户收到“开通0月蓝钻”邮件情况说明</font></font></a></li>
</ul>

 

 

document.domain='qq.com';
var announce_div_id;

// ---公告拉取--- //
function announce_init(aid)
{
 var xmlHttp;
 announce_div_id = aid;
 var stamp = Math.random() * 100000000000000000;
  send("http://service.qq.com/announce.html?nocache=" + stamp, "GET");
}

function createXMLHttpRequest()
{
   if(window.ActiveXObject)
   {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
   }
   else if(window.XMLHttpRequest)
   {
   xmlHttp = new XMLHttpRequest();
   }
}

function send(ur,meth)
{
 var ifIE = !!document.all;
 createXMLHttpRequest(); 
 xmlHttp.open(meth,ur,false);
 if (ifIE)
 {
  xmlHttp.onreadystatechange = announce_callback;
 }
 xmlHttp.send(null);
 if (!ifIE)
 {
  if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
  {
   var mes = xmlHttp.responseText;
   document.getElementById(announce_div_id).innerHTML=mes;
   scrollText.init(announce_div_id, 80);
     scrollText.scrollUp();
  }
 }
}

function announce_callback()
{
 if(xmlHttp.readystate == 4)
 {
  if(xmlHttp.status == 200)
  {
     var mes = xmlHttp.responseText;
      document.getElementById(announce_div_id).innerHTML=mes;
      scrollText.init(announce_div_id, 50);
     scrollText.scrollUp();
  }
 }
}

// --- 滚动效果 --- //
function next(elem)
{
        do
        {
         elem=elem.nextSibling;
        }
        while(elem&&elem.nodeType!=1);
        return elem;
}

function first(elem)
{
 elem=elem.firstChild;
 return elem && elem.nodeType!=1?next(elem):elem;
}

var scrollText=
{
 init:function(scrollbox,speed)
 {
  this.boxID = scrollbox;
  this.scrollSpeed = speed || 50;
 },
 obj : function()
 {
  var scrollBox = document.getElementById(this.boxID);
  var appendBox=first(scrollBox).cloneNode(true);

  scrollBox.appendChild(appendBox);
  return {
                   scrollBox : scrollBox,
                   appendBox : appendBox,
                   scrollSpeed :scrollText.scrollSpeed
            };
 },
 scrollUp : function()
 {  
  var m = this.obj();
  var doTimeout;
  var doScr = setInterval(function(){
                  if(m['appendBox'].offsetHeight <= m['scrollBox'].scrollTop)
                  {
                     m['scrollBox'].scrollTop -= m['appendBox'].offsetHeight;
                  }
                  else if (m['scrollBox'].scrollTop % m['scrollBox'].firstChild.firstChild.offsetHeight == 0)
                  {
                   clearInterval(doScr);
                   doTimeout = setTimeout(function(){
                   scrollText.init(m['scrollBox'].id, m['scrollSpeed']);
                   scrollText.scrollUp();},1000);
                   
                   m['scrollBox'].scrollTop++;
                  }
                  else
                  {
                     m['scrollBox'].scrollTop++;
                  }
               },
               this.scrollSpeed
              );
               
   m['scrollBox'].onmouseover=function()
        {
                clearInterval(doScr);
                clearTimeout(doTimeout);
            }
 
            m['scrollBox'].onmouseout=function()
            {    
                clearInterval(doScr);
                scrollText.init(this.id, m['scrollSpeed']);
                scrollText.scrollUp();
            }
 }
}

 

posted on 2011-08-13 14:55  西湖浪子  阅读(189)  评论(0)    收藏  举报