HomeJavaScript Page 4 - Controlling Browser Properties with JavaScript
Bar Tales - JavaScript
Maybe you know how to make Web pages dance to your tune with JavaScript - but how about making the browser do the same? This tutorial focuses on the important browser objects (including the Window, Location and History objects) that are controllable via JavaScript, showing you how to manipulate and use them in your scripts.
The status bar, located at the bottom of the browser window, has long been a territory abused by unimaginative developers. The default text that appears in this area may be altered via the Window object's "status" property, as in the following example:
<script language="JavaScript"> window.status = "The evil that men do in this bar lives after them" </script>
A common use of the "status" property is to display a scrolling ticker-tape in the status bar. Here's how:
<html> <head> <script language="JavaScript"> // ticket-tape message var message = "Yo ho ho and a bottle of rum";
In this case, I've created the appearance of a moving tickertape by taking one character off the beginning of the message string and adding it to the end. Each time the tickerTape() function calls itself, the first character of the string is deleted and added to the end of the string, simulating a scrolling ticker-tape. The setTimeout() function performs this add-and-remove function once every 75 milliseconds. Finally, the "status" property is used to assign the result at each stage to the browser's status bar.