zoukankan      html  css  js  c++  java
  • title向左_右滚动效果

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
     <head>
     <title>我爱自己想</title>
      <script type="text/javascript">
        //效果:向左,向右滚动.
        //setInterval事件.
        var dir='left';


        setInterval(function (){

           if(dir==='left'){
          //实现向左滚动
            var firstDoc=document.title.charAt(0);    
            var others=document.title.substring(1,document.title.length);
            document.title=others+firstDoc;
       
           }else if(dir==='right'){

           var lastDoc=document.title.charAt(document.title.length-1);
        
           var others=document.title.substring(0,document.title.length-1);
        
           document.title=lastDoc+others;    }
          },1000);
       
       //为两个button注册单击事件
         window.onload=function (){
          //left:
          document.getElementById('idLeft').onclick=function (){
            dir='left';
            }
         //right;
           document.getElementById('idright').onclick=function (){
            dir='right';
          }
       }
      </script>
     </head>
       
     <body>   
        <input type="button" name="name" value="left" id="idLeft" onclick="leftMoths()"></input>
        <input type="button" name="name" value="right" id="idright" onclick="rightMoths()"></input>

     </body>
    </html>

  • 相关阅读:
    一个经典的页面布局
    巧避new的一个原型设计模式
    讲解关于javascript的继承
    根据指定日期 算出该周的一周日期
    原型实现的一个观察者模式
    减少类之间的耦合性
    Android 代码下载
    (转)open gl 实例 demo vs2005 环境
    Tile editor 快捷键
    这是第一篇博客~
  • 原文地址:https://www.cnblogs.com/nqsan/p/3182895.html
Copyright © 2011-2022 走看看