The Java Scriptorium

Scrolling Status Bar Text


Description

Displays scrolling text in the staus bar of your browser.

Example

See status bar or hit 'reload'.

Code

In the <head> section of your document:

<!-- JavaScript -->
<SCRIPT LANGUAGE="JavaScript">
<!--
// the string that should scroll
var scrlStr = "Scrolling Text"

// the width of the scrolling area
var width = 120;

var strLen = scrlStr.length;
var pos = 1 - width;                // start far enough to the left for only
                                    // one letter to be showing

function scroll(){
    var scroll = "";                // initialize the string to be printed
    pos++;                          // move to the right in the string
    if (pos == strLen)              // start over if the string is done
        pos = 1 - width;            // scrolling

    if (pos<0) {                    // add spaces to beginning if necessary
        for (var i=1; i<=Math.abs(pos); i++)
            scroll = scroll + " ";  
       scroll = scroll + scrlStr.substring(0, width - i + 1);
    }
    else
        scroll = scroll + scrlStr.substring(pos, pos + width);

    window.status = scroll;         // print the string
    setTimeout("scroll()",100);     // recurse after 1/10 of a second
}

//-->
</SCRIPT>

In the <body> section of your document:

<body ONLOAD="scroll(); return true">

Return to the Java Scriptorium.