The JavaScript Programming Language

Scrolling Text Example Program


Click below to go directly to a specific section:
Description| Scrolling Text Source Code| Sample Run

Scrolling Text Description

Text scrolls at the bottom of the Browser.

Scrolling Text Source Code




<HTML>

<SCRIPT LANGUAGE="JavaScript">

<!-- JavaScript scroll function --



function scroll(seed)

{

     var msg  = "Look at me go! I'm scrolling!";

     var out   = " "

     var i     = 1

        

     if (seed > 100) {

          seed--;

          var cmd  = "scroll(" + seed + ")";

          timerTwo = window.setTimeout(cmd,100);

     }

     else if (seed <= 100 && seed > 0) {

          for (i = 0 ; i < seed ; i++) {

               out += " ";

          }

          out += msg;

          seed--;

          var cmd = "scroll(" + seed + ")";

          window.status=out;

          timerTwo=window.setTimeout(cmd,100);

     }

     else if (seed <= 0) {

          if (-seed < msg.length) {

               out += msg.substring(-seed,msg.length);

               seed--;

               var cmd="scroll(" + seed + ")";

               window.status=out;

               timerTwo=window.setTimeout(cmd,100);

          }

          else {

               window.status=" ";

               timerTwo=window.setTimeout("scroll(100)",75);

          }

     }

 }



</SCRIPT>

<BODY onLoad="timerONE=window.setTimeout('scroll(100)',500);">



</BODY>

</HTML>




Scrolling Text Sample Run

View Navigator Bar at bottom of Browser Window.
[Back] [Home]

Last Modified: 01:40 PM on 11/15/1999