Most of you have been in airports or train stations and seen the big screens that inform you that a plane or train is boarding, late, or cancelled. This information has to come from somewhere, and it has to be controlled by some kind of timer. This tip will show you a technique to do that sort of thing.
I've seen my share of dull examples showing item masters or customer sales. But everybody has a favorite song, so I'll use "top hits" for my example. You can vote and even learn something useful too!
To give you an overview, here is what you get:
- A "top hits" program, which also lets you cast a vote
- A setup program from which you can dynamically change the look of the hit list
- A way to prompt for colors
- Some JavaScript knowledge you might not be aware of
So the tone is set. Let's roll.
How to Refresh a Web Page
There are two ways (that I am aware of) you can refresh a Web page.
You can use a meta tag, which is placed in the
The meta tag looks like this:
This tells the browser that it should reload the page every 10 seconds by calling program form010.
(Note: In IE 7.0, you can disable the meta refresh, so if you have done that and also disabled JavaScript, this won't work.)
I have always used the meta tag method, but some clever people do things a better way. On GrizzlyWeb.com, I found a very good and useful JavaScript Refresh example that also taught me something about JavaScript that I never knew.
When you use JavaScript in an HTML document, you can write