欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS實(shí)現(xiàn)簡(jiǎn)單的鍵盤(pán)打字的效果

 更新時(shí)間:2015年04月24日 10:37:21   投稿:hebedich  
本文給大家分享的是使用javascript實(shí)現(xiàn)的簡(jiǎn)單的鍵盤(pán)打字效果,十分的簡(jiǎn)單實(shí)用,推薦給有需要的小伙伴參考下。

以代碼形式實(shí)現(xiàn)過(guò)程分析:

<html>
<head>
<title>打字效果</title>
<meta http-equiv="Content-Type" Content="text/html;charset=gb2312" />
<style type="text/css">
body{
  font-size:14px;
  font-color:#purple;
  font-weight:bolder;
}
</style>
</head>
<body>
最新內(nèi)容: <a id = "Hotnews" href="" target="_blank"> </a>  
<script language="javascript">
  var NewsTime = 2000;    //每條信息完整出現(xiàn)后停留時(shí)間
  var TextTime = 100;    //每條信息中的字出現(xiàn)的間隔時(shí)間
  
  var newsi = 0;
  var txti = 0;
  var txttimer;   //調(diào)用setInterval的返回值,用于取消對(duì)函數(shù)的周期性執(zhí)行
  var newstimer;
  
  var newstitle = new Array();    //以數(shù)組形式保存每個(gè)信息的標(biāo)題
  var newshref = new Array();   //以數(shù)組形式保存信息標(biāo)題的鏈接
  
  newstitle[0] = "歡迎來(lái)到我的博客";   //顯示在網(wǎng)頁(yè)上的文字內(nèi)容和對(duì)應(yīng)的鏈接
  newshref[0] = "http://www.dbjr.com.cn/guihailiuli/";
  
  newstitle[1] = "http://www.dbjr.com.cn/guihailiuli/";
  newshref[1] = "http://www.dbjr.com.cn/guihailiuli/";
  
  newstitle[2] = "博客園歡迎你哦";
  newshref[2] = "http://www.dbjr.com.cn";
  
  newstitle[3] = "ByeBye~~";
  newshref[3] = "http://www.dbjr.com.cn";
  
  function shownew(){
    hwnewstr=newstitle[newsi];    //通過(guò)newsi傳遞,依次顯示數(shù)組中的內(nèi)容
    newslink=newshref[newsi];     //依次顯示文字對(duì)應(yīng)的鏈接
     
    if(txti>=hwnewstr.length){
      clearInterval(txttimer);  //一旦超過(guò)要顯示的文字長(zhǎng)度,清除對(duì)shownew()的周期性調(diào)用
      clearInterval(newstimer); 
      newsi++;   //顯示數(shù)組中的下一個(gè)
      
      if(newsi>=newstitle.length){
        newsi = 0;  //當(dāng)newsi大于信息標(biāo)題的數(shù)量時(shí),把newsi清零,重新從第一個(gè)顯示
      }
      newstimer = setInterval("shownew()",NewsTime);   //間隔2000ms后重新調(diào)用shownew()
      txti = 0;  
      return;
    }
    clearInterval(txttimer);  
    document.getElementById("Hotnews").href = newslink;  
    document.getElementById("Hotnews").innerHTML = hwnewstr.substring(0,txti+1);   //截取字符,從第一個(gè)字符到txti+1個(gè)字符
    
    txti++;  //文字一個(gè)個(gè)出現(xiàn)
    txttimer = setInterval("shownew()",TextTime);   
  }
  shownew();

</script>
</body>
</html>

以上所述就是本文的全部?jī)?nèi)容了,希望能夠給大家學(xué)習(xí)javascript有些幫助。

相關(guān)文章

最新評(píng)論