Web Page CentralPoliciesHTMLFAQPublishingBookletToolsLinks

Home :: Learning HTML :: Counters

Search

[Help]
Match:

[Off Site Link]=Off Site Link[Help]

[Direct Link to File]=Link to File[Help]

Counters

Contents:

Counter Concepts

We'll start out with a random piece of HTML used to make a counter in order to describe what's going on. Some various options can be seen later in Counter Examples.

Example HTML from the Staff & Organization Development Home Page, located at http://www.madison.k12.wi.us/sod/index.htm
<IMG SRC="/Count.cgi?df=sod.index.htm&amp;ft=0&amp;dd=B&amp;pad=0" HEIGHT="20" ALT="At least 4000"> visitors since November 10, 1997.

The name of the program we use is "Count.cgi" (notice the capital "C"). Anything after the "?" are options you can set to affect the appearance of the counter. Options are separated by ampersands; remember, ampersands are special characters, so they need to be written as &amp;. The most important option is "df". Every counter needs the option "df" set. "df" sets the name of a file which holds the number of hits the counter on the document has received. Therefore it is also important that each counter has a unique value of "df". In the example above, "df" is set to "sod.index.htm". We've developed a system so that each document can have a unique counter.

In the example, the counter is on the document at http://www.madison.k12.wi.us/sod/index.htm and the counter's "df" is set to equal "sod.index.htm". This follows the pattern:

  1. Take the full URL of the document; e.g. http://www.madison.k12.wi.us/sod/index.htm
  2. Remove the http://www.madison.k12.wi.us/; e.g. sod/index.htm
  3. Change all slashes (/) to periods (.); e.g. sod.index.htm

This way, since all documents have unique URLs, they will also have unique "df"s.

Return to the Top


Counter Examples & Samples

Counter Examples

A Web document named "afrlands.htm" is published in category "webpub_01".

The Document's URL:
http://www.madison.k12.wi.us/webpub/01/afrlands.htm
Counter File Name:
df=webpub.01.afrlands.htm
Complete Counter Tag:
<IMG SRC="http://www.madison.k12.wi.us/Count.cgi?df=webpub_01.afrlands.htm" ALT="">

A Web document named "afrlands.htm" is published in a directory name "sstudies" of category "east".

The Document's URL:
http://www.madison.k12.wi.us/east/sstudies/afrlands.htm
Counter File Name:
df=east.sstudies.afrlands.htm
Complete Counter Tag
<IMG SRC="http://www.madison.k12.wi.us/Count.cgi?df=east.sstudies.afrlands.htm" ALT="">

Some Sample Counters

For each counter, notice the counter's "df" is "webpub.advanc40.htm"; that's because this page's address is http://www.madison.k12.wi.us/webpub/advanc40.htm. Notice, also, that there are no spaces in the options and options are separated by the text "&amp;" (no quotes).

Since counters are images, they require ALT text. However, coming up with ALT text for a constantly changing graphic can be difficult, to say the least. If the page is updated frequently, you could put the current number of hits rounded down to the nearest 50 or 100. Otherwise, you could use ALT="" or ALT="lots", ALT="some", etc.

One last thing: Counters cannot be reset. If you'd like to remove a counter and start a new one on a document, just give the "df" a new name by adding .2 to the end; e.g. from df=webpub.index.htm to df=webpub.index.htm.2

The Basic Tag

The HTML
<img src="http://www.madison.k12.wi.us/Count.cgi?df=webpub.advanc40.htm" ALT="">
Counter Image

No Frame Around the Counter Image

Add the option ft=1. Add an &amp; to separate options.

The HTML
<img src="http://www.madison.k12.wi.us/Count.cgi?df=webpub.advanc40.htm&amp;ft=1" ALT="">
Counter Image

Wider Frame

Add the option ft=n (n = width of frame in pixels). Add an &amp; to separate options.

The HTML
<img src="http://www.madison.k12.wi.us/Count.cgi?df=webpub.advanc40.htm.&amp;ft=15" ALT="">
Counter Image

No Padding of Zeros

Add the option pad=0. Add an &amp; to separate options.

The HTML
<img src="http://www.madison.k12.wi.us/Count.cgi?df=webpub.advanc40.htm&amp;pad=0" ALT="">
Counter Image

No Padding, Frame Size Equals 10 Pixels and the Counter Starts at 900

Add the option st=n (n = starting number of count). Add an &amp; to separate options.

The HTML
<img src="http://www.madison.k12.wi.us/Count.cgi?df=webpub.advanc40.htm&amp;pad=0&amp;ft=10&amp;st=900" ALT="">
Counter Image

Different Number Graphics

Add the option dd=X, where X = A, B, C, D, or E. There are 5 sets of graphics; each is represented by a letter. Note that the letters must be capitalized. Add an &amp; to separate options.

The HTML
<img src="http://www.madison.k12.wi.us/Count.cgi?df=webpub.advanc40.htm&amp;pad=0&amp;dd=C" ALT="">
Counter Image

Previous: Special Characters
Next: Image Maps


Home:: Learning HTML :: Counters

Home | Policies | HTML | FAQ
Publishing | Booklet | Tools | Links

Last Update: 1999-06-01
This Page's Address: http://www.madison.k12.wi.us/webpub/advanc40.htm
District Home Page: http://www.madison.k12.wi.us
HTML Editor & Publisher: Chris Burch, cburch@madison.k12.wi.us
webmaster@madison.k12.wi.us