First, frequently asked questions
1, about this FAQ (about this FAQ)
Q: Why use this FAQ?
a: The purpose of this FAQ is to help you develop strong client-side scripts that can run on Netscape Navigator as well as on Microsoft Internet Explorer and under a variety of operating systems. This FAQ collects content that is different from the following:
Here the answer is based on platform-independent coding, not for a particular browser or platform.
Most of the answers here contain interactive code that you can run and get results without leaving the page you're browsing: This needs to be run on the original text and clicked on the title to get into the original text.
Netscape Navigator (starting from 2.0)
Microsoft Internet Explorer (starting from 3.0)
Give users more control over the browser
Detects user's browser, operating system, screen size, etc.
Perform a simple calculation on the client
Validating the user's input
Processing date and time
Do not access the Web server to generate HTML pages during run
Below you will find a few simple examples to illustrate each task.
I. Give users more control over the browser
Example : Here you can modify the background color of the page, as well as the text on the browser status bar.
II. Detect the user's browser and operating system. . If needed, this ability detects user's browser and operating system information, allowing you to perform platform-related operations.
example , users of different browsers receive different greetings:
Iii. perform a simple calculation on the client.
Iv. Verify the number of user input.
example : In the above calculator, if you enter letters instead of numbers, you get a warning: invaid input characters!
v. Processing date and time.
Example 2: This script will say "nice morning, isn ' t it?" according to the current time. or "Good afternoon!." Or "Wow, you are isn't sleep yet!?". It will also tell you the date of today.
VI. Generate HTML pages in run.
Example : The directory on the left (translator Note: In the original text, the left side is a directory) is dynamically expanded. To view all the subkeys of an item, click the white arrow corresponding to it. When hiding, click the arrow.