How to create a simple counter using JavaScript _ basic knowledge-js tutorial

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.