• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 逐行滾動文字效果的Javascript實現

    發表于:2007-06-21來源:作者:點擊數: 標簽:
    /* 本程序根據21cn的一個版本改進而來。 * 原版本實現的思路是:在一個大小只有一行的層里生成一個表格,然后使用 * TABLE的scrollTop來實現逐行滾動。但這個方法只能在IE中正常運行,在Mozzila 就無法滾動。 * 改進后使用 IFrame 來代替原來的層,使用BODY

       

    /* 本程序根據21cn的一個版本改進而來。
    *  原版本實現的思路是:在一個大小只有一行的層里生成一個表格,然后使用
    *  TABLE的scrollTop來實現逐行滾動。但這個方法只能在IE中正常運行,在Mozzila 就無法滾動。

    *  改進后使用 IFrame 來代替原來的層,使用BODY的scrollTop來實現滾動。
    *  BTW:DannyKang 是我英文名寫法。
    */


    //FILE: scrolltext.js CREATED: DannyKang @ 2004-5-19
    var stopscroll=false;
     var preTop=0;
     //var newTop=0;
     var currentTop=0;
     var stoptime=0;
     var iInterval ;


     function init_srolltext(){
     document.body.scrollTop=0;
     document.body.onmouseover   = new Function("stopscroll=true");
     document.body.onmouseout    = new Function("stopscroll=false");
     document.body.oncontextmenu = new Function("return false;");
     document.body.onselectstart = new Function("return false;");
     iInterval = setInterval("scrollUp()",25);
     }


     function scrollUp(){
      if(stopscroll==true) return;
      currentTop+=1; //每次滾動 1 個象素
      if(currentTop==24){ //剛滾動完一行后(每行高23)
       stoptime+=1;  //停頓時間累計 1 個單位時間(25毫秒)
       currentTop-=1; //滾動位移數恢復原值
       if(stoptime==100){ //停頓時間累計 100 個單位時間后重新計算滾動位移和停頓時間
        currentTop=0;
        stoptime=0;
        //if(confirm("One line end ...... \n\nok to stop , cancel to go on.")){clearInterval(iInterval);}
       }
      }else{   
       document.body.scrollTop = preTop +1; //滾動 1 個象素
       if(preTop< document.body.scrollTop){
        preTop = document.body.scrollTop ;
       }
       else {//如果滾動到末尾了(滾動跟沒滾一樣)
        preTop = 1
        document.body.scrollTop = 1;
        //if(confirm("scroll to all text ending.......["+preTop+"/"+document.body.scrollTop+"] \n\nok to stop , cancel to go on.")){clearInterval(iInterval);}
       }
      }
     }
     
     init_srolltext(); //啟動


    /*調用頁面的IFrame 寫法*/
    <iframe id="adtxt1" align="center" style="WIDTH: 590;  HEIGHT: 23" src="index_js/adtxt1.htm" name="iframe1" frameborder="0" scrolling="no"></iframe>


    /*滾動內容的HTML頁面 adtxt1.htm 源代碼*/
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD><TITLE>滾動新聞</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=gb2312">
    <STYLE type=text/css>
    body,TD {
     FONT-SIZE: 9pt
    }
    </STYLE>
    <BODY scroll=no leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <table border=0 align="center" cellpadding=0 cellspacing=0>
      <tr>
        <td height=23 align="center" nowrap><a target="_blank">中山市“美好生活一瞬間”數碼攝影比賽</a>  
          <a target="_blank"><font color="#FF0000">中國商業技師協會職業資格權威認證培訓</font></a>
        </td>
      </tr>
      <!--頭條:與尾條相同內容-->
      <tr>
        <td height=23 align="center" nowrap><a target="_blank">“好山好水好兒女”中山文化名人推廣月</a>  
          <a target="_blank">中山市勞動和社會保障工作情況通報</a></td>
      </tr>
      <!--tr>
        <td height=23 align="center" nowrap> </td>
      </tr-->
      <!--尾條:與頭條相同內容-->
      <tr>
        <td height=23 align="center" nowrap> <a target="_blank">中山市“美好生活一瞬間”數碼攝影比賽</a>  
          <a target="_blank"><font color="#FF0000">中國商業技師協會職業資格權威認證培訓</font></a>
        </td>
      </tr>
    </table>
    <!-- 放在body內最后一行 -->
    <SCRIPT language=JavaScript src="scrolltext.js"></SCRIPT>
    </BODY>
    </HTML>


    /*調用頁面演示效果見:http://www.zhongshan.gd.cn */

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>