The following is the complete source code for the scrolling status bar script. This page is for reference only. To actually use the code, either save the source from the example file, or you can retrieve the scroll.js source file.
<!-- Websys, Inc. Copyright (C)1996, All Rights Reserved. Websys is a registered trademark of Web Integration Systems, Inc. For information, the newest source code, and other JavaScript applications, questions and comments please contact us via the following resources: http://websys.com/javascript/index.html javascript@websys.com Sending email to the javascript email address will also automatically register you in our mailing list. If you do NOT want notices of new code, common problem solutions, and updates, please write "UNLISTED" by itself in the first line of your correspondence. We will have a listserver setup in the near future, and I also try to keep up with the comp.users.javascript newsgroup. This source code is hereby released to the public domain with the understanding that credit to Websys will be left in the source comments. Your questions, suggestions, and comments are appreciated, however we may not be able to personally respond to every query. We are building a FAQ on the website, so please check there for your problem first. Happy Coding! Chris Skinner Vice President of Information Systems Web Integration Systems, Inc. (WEBSYS) chris@websys.com --> <!-- DISCLAIMER and LICENSE Web Integration Systems, Inc. (Herein known as Websys) releases the source code for this application into the public domain with the following provision: 1. Credit for original development and a reference to our website (http://websys.com/) must be included in the comments for the source code. Permission to use, copy, modify, and distribute this software and its documentation for NON-COMMERCIAL or COMMERCIAL purposes and without fee is hereby granted. WEBSYS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. WEBSYS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES"). SUN SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES. --> <SCRIPT LANGUAGE="JavaScript"> /* Please note that the comment method described by Netscape for hiding JavaScript code from old browsers does NOT work for many non-Netscape browsers. This unfortunate problem can be solved by writing a small CGI script that is called as a server side include. Stay tuned for shareware code available on our site to do this! */ /* Create an indexed array of n elements with length property */ function mklist(n) { this.length=n; for (var c=1 ; c <= n ; c++) { this[c]=0; } return this; } /* Gets a browser platform specific delay calibration for scrolling messages */ function browserdelay() { var retval=500; if (navigator.userAgent.indexOf("Win") != 0) { /* Windows based Netscape */ retval=150; } else if (navigator.userAgent.indexOf("Mac") != 0) { /* Mac based Netscape */ retval=500; } else if (navigator.userAgent.indexOf("X11") != 0) { /* XWindows based Netscape */ retval=750; } return retval; } /* Create the configuration object for scrollit */ function mkcfg(n) { this.num=1; /* Which message we're on */ this.seed=0; /* Used for scrolling types */ this.list=new mklist(n); /* List of messages to display */ this.type=new mklist(n); /* Display method indicators */ this.delay=browserdelay(); /* Browser platform specific delay */ this.timer=0; /* System event timer */ this.showurl=(5 * 1000); /* Timeout for urlfix functionality */ this.looping=true; /* Continuously rotate messages? */ this.msgdisp=(5 * 1000); /* How long to display non-scrolling messages */ this.barwidth=100; /* How many character to size the status bar */ return this; } /* This function is used from within the page to display the url for a link */ function urlfix(obj) { window.clearTimeout(window.config.timer); window.defaultStatus=obj.href; window.config.timer=window.setTimeout("sbprint()",window.config.showurl); return true; } /* This function handles the right to left scrolling */ function scrollit_r2l() { var out=" "; var c=0; if (window.config.seed <= window.config.barwidth && window.config.seed > 0) { for (c=0 ; c < window.config.seed ; c++) { out+=" "; } out+=window.config.list[window.config.num]; window.config.seed--; window.status=out; window.config.timer=window.setTimeout("scrollit_r2l()",window.config.delay); } else if (window.config.seed <= 0) { if (-window.config.seed < window.config.list[window.config.num].length) { out+=window.config.list[window.config.num].substring(-window.config.seed,window.config.list[window.config.num].length); window.config.seed--; window.status=out; window.config.timer=window.setTimeout("scrollit_r2l()",window.config.delay); } else { window.status=" "; window.config.num++; window.config.timer=window.setTimeout("sbprint()",window.config.msgdisp); } } } /* Call the following with the number of different messages you want to run */ window.config=new mkcfg(2); window.config.list[1]="JavaScript is certainly fun!"; window.config.type[1]=0; /* Just display it, default type */ window.config.list[2]="Scrolling messages are nice and do not interfere with the rest of the display!"; window.config.type[2]=1; /* Scrolling from right to left */ /* This function runs the status bar, cycling through your messages */ function sbprint() { if (window.config.num <= window.config.list.length) { if (window.config.type[window.config.num] == 0) { window.status=window.config.list[window.config.num]; window.config.num++; window.clearTimeout(window.config.timer); window.config.timer=window.setTimeout('sbprint()',window.config.msgdisp); } else if (window.config.type[window.config.num] == 1) { window.config.seed=window.config.barwidth; scrollit_r2l(); } } else if (window.config.looping) { window.config.num=1; window.clearTimeout(window.config.timer); window.config.timer=window.setTimeout('sbprint()',window.config.delay); } } </SCRIPT>