• <abbr id="chdyf"></abbr>
    <ruby id="chdyf"><acronym id="chdyf"><meter id="chdyf"></meter></acronym></ruby>
    <bdo id="chdyf"></bdo>
    <dfn id="chdyf"><menu id="chdyf"></menu></dfn>
    1. <menuitem id="chdyf"></menuitem><strong id="chdyf"><menu id="chdyf"></menu></strong>

      <rt id="chdyf"><menu id="chdyf"></menu></rt>
      成人小说一区二区三区,伊人精品成人久久综合全集观看,久久HEZYO色综合,中文字幕精品人妻熟女,影音先锋成人网站,我要看免费一级毛片,中国女人做爰A片,中文字幕av久久爽Av

      Javascrpit之打字機(jī)效果

      2018-6-25    seo達(dá)人

      如果您想訂閱本博客內(nèi)容,每天自動發(fā)到您的郵箱中, 請點(diǎn)這里

      今天來看看怎么實(shí)現(xiàn)炫酷的打字機(jī)效果。即把一段話一個(gè)字一個(gè)字的顯示出來。

      效果圖:

      實(shí)現(xiàn)思路:

      首先規(guī)定好顯示字?jǐn)?shù)的速度即settimeout執(zhí)行間隔用來控制每個(gè)字之間輸出速度。再把判斷段落的總字?jǐn)?shù),循環(huán)段落總字?jǐn)?shù)來實(shí)現(xiàn)一個(gè)字一個(gè)字的輸出。

      js代碼:

      
          
      1. var theNewsNum;
      2. var theAddNum;
      3. var totalNum;
      4. var CurrentPosion=0;
      5. var theCurrentNews;
      6. var theCurrentLength;
      7. var theNewsText;
      8. var theTargetLink;
      9. var theCharacterTimeout;
      10. var theNewsTimeout;
      11. var theBrowserVersion;
      12. var theWidgetOne;
      13. var theWidgetTwo;
      14. var theSpaceFiller;
      15. var theLeadString;
      16. var theNewsState;
      17. function startTicker(){
      18. // ------ 設(shè)置初始數(shù)值
      19. theCharacterTimeout = 50;//字符間隔時(shí)間
      20. theNewsTimeout = 2000;//新聞間隔時(shí)間
      21. theWidgetOne = "_";//新聞前面下標(biāo)符1
      22. theWidgetTwo = "-";//新聞前面下標(biāo)符
      23. theNewsState = 1;
      24. theNewsNum = document.getElementById("incoming").children.AllNews.children.length;//新聞總條數(shù)
      25. theAddNum = document.getElementById("incoming").children.AddNews.children.length;//補(bǔ)充條數(shù)
      26. totalNum =theNewsNum+theAddNum;
      27. theCurrentNews = 0;
      28. theCurrentLength = 0;
      29. theLeadString = " ";
      30. theSpaceFiller = " ";
      31. runTheTicker();
      32. }
      33. // --- 基礎(chǔ)函數(shù)
      34. function runTheTicker(){
      35. if(theNewsState == 1){
      36. if(CurrentPosion<theNewsNum){
      37. setupNextNews();
      38. }
      39. else{
      40. setupAddNews();
      41. }
      42. CurrentPosion++;
      43. if(CurrentPosion>=totalNum||CurrentPosion>=1){
      44. CurrentPosion=0;//最多條數(shù)不超過num_gun條
      45. }
      46. }
      47. if(theCurrentLength != theNewsText.length){
      48. drawNews();
      49. }
      50. else{
      51. closeOutNews();
      52. }
      53. }
      54. // --- 跳轉(zhuǎn)下一條新聞
      55. function setupNextNews(){
      56. theNewsState = 0;
      57. theCurrentNews = theCurrentNews % theNewsNum;
      58. theNewsText = document.getElementById("AllNews").children[theCurrentNews].children.Summary.innerText;
      59. theTargetLink = document.getElementById("AllNews").children[theCurrentNews].children.Summary.children[0].href;
      60. theCurrentLength = 0;
      61. document.all.hottext.href = theTargetLink;
      62. theCurrentNews++;
      63. }
      64. function setupAddNews() {
      65. theNewsState = 0;
      66. theCurrentNews = theCurrentNews % theAddNum;
      67. theNewsText = document.getElementById("AllNews").children[theCurrentNews].children.Summary.innerText;
      68. theTargetLink = document.getElementById("AllNews").children[theCurrentNews].children.Summary.children[0].href;
      69. theCurrentLength = 0;
      70. document.all.hottext.href = theTargetLink;
      71. theCurrentNews++;
      72. }
      73. // --- 滾動新聞
      74. function drawNews(){
      75. var myWidget;
      76. if((theCurrentLength % 2) == 1){
      77. myWidget = theWidgetOne;
      78. }
      79. else{
      80. myWidget = theWidgetTwo;
      81. }
      82. document.all.hottext.innerHTML = theLeadString + theNewsText.substring(0,theCurrentLength) + myWidget + theSpaceFiller;
      83. theCurrentLength++;
      84. setTimeout("runTheTicker()", theCharacterTimeout);
      85. }
      86. // --- 結(jié)束新聞循環(huán)
      87. function closeOutNews(){
      88. document.all.hottext.innerHTML = theLeadString + theNewsText + theSpaceFiller;
      89. theNewsState = 1;
      90. setTimeout("runTheTicker()", theNewsTimeout);
      91. }
      92. window.onload=startTicker;
      藍(lán)藍(lán)設(shè)計(jì)m.wtxcl.cn )是一家專注而深入的界面設(shè)計(jì)公司,為期望卓越的國內(nèi)外企業(yè)提供卓越的UI界面設(shè)計(jì)、BS界面設(shè)計(jì) 、 cs界面設(shè)計(jì) 、 ipad界面設(shè)計(jì) 、 包裝設(shè)計(jì) 、 圖標(biāo)定制 、 用戶體驗(yàn) 、交互設(shè)計(jì)、 網(wǎng)站建設(shè) 、平面設(shè)計(jì)服務(wù)

      日歷

      鏈接

      個(gè)人資料

      存檔

      主站蜘蛛池模板: 吃奶呻吟打开双腿做受动态图| 亚洲日韩AV在线| 营山县| 亚洲精品漫画一二三区| 午夜一区二区三区| 日本阿v精品视频在线观看 | 国产欧美一区二区高清在线| 精品国产一区二区三区四区| 两个人的免费视频| 国产精品久免费的黄网站| ,国产乱人伦无无码视频| 人妻无码系列一区二区三区| 亚洲精品成人午夜在线| 国产六月婷婷爱在线观看| 久久影院一区二区h| 久久久精品人妻一区二区三区日本 | 天堂av中文| 天堂一区在线观看| 牛牛澡牛牛爽一区二区| 免费人成黄页在线播放| 久久香蕉国产线看观看精品蕉| 班玛县| 99r精品在线| 精品人妻免费看一区二区三区 | 国产精品中文| A级片网站| 日韩av一区二区三区在线| 丁香婷婷五月| 夜色福利久久精品福利| 亚洲AV无码一区东京热久久| 日本无码中文| 久久一二三四区中文字幕| 在线亚洲精品国产成人二区| 色翁荡媳又硬又粗又长视频| 97成人精品视频在线观看| 中文字幕有码无码人妻AV蜜桃| av中文字幕在线一区| 欧美AA视频| 在线精品动漫一区二区无码| 欧美自拍视频| 国产丝袜打飞机免费在线|