Quotes help make search much faster. Example: "Practice Makes Perfect"

Saturday, March 23, 2013

Scrolling Text Using Javascript



This is the scrolling text.

Code for the scrolling effect is written below:

<style type="text/css">
#scroll{
         position : absolute;
      white-space : nowrap;
              top : 0px;
             left : 200px;
       }
#oScroll{
    margin : 1px;
   padding : 0px;
         position : relative;
            width : 450px; /* width of the scroll box */
           height : 20px;
         overflow : hidden;
        }
      </style>
      <script type="text/javascript">
     function scroll(oid,iid){
          this.oCont=document.getElementById(oid)
          this.ele=document.getElementById(iid)
          this.width=this.ele.clientWidth;
          this.n=this.oCont.clientWidth;
          this.move=function(){
             this.ele.style.left=this.n+"px"
             this.n--
             if(this.n<(-this.width)){this.n=this.oCont.clientWidth}
                              }
                             }
     var vScroll
     function setup(){
         vScroll=new scroll("oScroll","scroll");
         setInterval("vScroll.move()",50) //controls the speed of scrolling, higher means slower
                     }
  onload=function(){setup()}
      </script>
<br />
<div id="oScroll">
<div id="scroll">
This is the <a href="http://questionsans.blogspot.com/2013/03/scrolling-text-using-javascript.html">scrolling text</a></div>
</div>

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts