www.insideDHTML.com
Inside Dynamic HTML | Fun and Games | The 10K Demo | XML Online | CSS Online | Resources
Write Once! | DHTML Toolkits | Inside Techniques | Inside Scriptlets

Inside Techniques/

   

scrollo() Function

The scrollo() function scrolls text from right to left on the status bar of the browser. This function runs in both Navigator and Internet Explorer.

For example, to start scrolling text as soon as the page loads:

   <body onload="scrollo('Welcome to Inside Dynamic HTML. I hope you find these functions useful!');">

This page will scroll the above string (the string may take some time to appear as the function adds 200 leading spaces.)

scrollo() Function

function scrollo(x) {
        if (document.scrollText == null) {
                document.scrollText = "";
                for (i = 0; i < 200; i++) {
                        document.scrollText = document.scrollText + " ";
                }
                document.scrollText = document.scrollText + x;
                document.scrollNum = 0;
                document.scrollMsg = "";
                document.scrollGo = "1";
        }

        if (document.scrollText != null && document.scrollGo == "1") {
                for (k = document.scrollNum; k < document.scrollText.length; k++) {
                        document.scrollMsg = document.scrollMsg + document.scrollText.charAt(k);
                }
                window.status = document.scrollMsg;
                document.scrollNum++;
                document.scrollMsg = "";
        }

        if (document.scrollNum == document.scrollText.length) {
                document.scrollText = null;
        }

        ab1 = window.setTimeout("scrollo('"+ x +"');", 50);
}