This article describes how to use JavaScript to create a simple counter, which is used to calculate the number of visits of Web users. For more information, see
Design Philosophy
The key to this method is the comprehensive use of Cookie technology and dynamic image features. Cookie can be used to record user data on the hard disk of the user end. When you visit the site next time, you can read the Cookie on the hard disk of the user end and directly learn the identity and access times of the visitor. In JavaScript, the document. cookie attribute is used to access the Cookie. This attribute includes the name, expiration date, valid domain name, and valid URL path. The names and values separated by equal signs are the actual data of cookies. In this example, they are used to store the number of times the visitor accesses the page. By ing Images on the Web page to an Images array, you can modify the attributes of this array under certain conditions to achieve dynamic image display. In this example, a set of images are pre-loaded. Each time the web page is called, a new set of images are randomly generated to achieve dynamic and interesting effects by overwriting the original image.
Source program count.html
<Html>
Notes
Because JavaScript is used, this method is independent from the application platform and can be applied to Unix, Windows, and other platforms. In addition, this counter is different from the visitor counter in the general sense and is used to record the number of visits a visitor has to a website.