Developer

Stupid Web Tricks: Add scrolling text to the bar below the browser window

Provide your Web visitors with essential information by adding a scrolling text bar beneath the browser window. Learn how.

Click here for our complete list of Stupid Web Tricks.

You've seen them all over the Web, providing such essential information as which celebrities are close to death. Scrolling text in the bar below the browser window is an easy way to provide pseudodynamic content and captivate your readers by gradually revealing what you have to say—even if, as is often the case, what you have to say isn't all that captivating. As it turns out, you may find it a lot easier to add the scrolling text than to actually write it.

Step One
Paste the following code into the <HEAD> of your document:

<SCRIPT language="JavaScript">
<!— hide javascript

function scrollmessage(count) {

var m1 = "Your first sentence goes here";
var m2 = "...and your second one goes here";
var m3 = "...and a third one here";
var m4 = "...and a fourth!";
var msg=m1+m2+m3+m4;
var out = " ";
var c = 1;

if (count > 100) {
   count—;
   cmd="scrollmessage("+seed+")";
   timerTwo=window.setTimeout(cmd,100);
   }

else if (count <= 100 && count > 0) {
   for (c=0 ; c < count ; c++) {
      out+=" ";
      }
   out+=msg;
   count—;
   window.status=out;
   cmd="scrollmessage("+count+")";
   timerTwo=window.setTimeout(cmd,100);
   }

else if (count <= 0) {
   if (-count < msg.length) {
      out+=msg.substring(-count,msg.length);
      count—;
      window.status=out;
      cmd="scrollmessage("+count+")";
      timerTwo=window.setTimeout(cmd,100);
      }
   else {
      window.status=" ";
      timerTwo=window.setTimeout("scrollmessage(100)",75);
      }
   }

}

// done hiding —>
</SCRIPT>

Be sure to replace our sample text (Your first sentence goes here and so forth) with your own clever commentary.

Step Two
Add the following text to your document's <BODY> tag:

<BODY onLoad="scrollmessage(100)">

That's it. Remember, scrolling text is no excuse to deliver annoying messages.

Editor's Picks