Basic JavaScript Q & A 1

Source: Internet
Author: User

I saw a very good JavaScript FAQ on the internet today. I was worried that I could not read it all the time, so I tried to translate some content and share it with my friends.
FAQ address: http://www.javascripter.net/faq/index.htm

I. FAQs

1. About this FAQ (About this FAQ)

Q: Why is this FAQ used?

A: The purpose of this FAQ is to help you develop strong client scripts. It can run not only on Netscape Navigator, but also on Microsoft Internet Explorer, it is in various operating systems. The content collected by this FAQ is different from the following:

The answer here is based on platform-independent encoding, rather than targeting a specific browser or platform.
Most of the answers here contain interactive code that can run and get results without leaving the page you are browsing, click the title to enter the original text ).

Here you can find a solution to the problem, not just to confirm that the problem exists. For example, other resources may say: Sorry, JavaScript cannot read files from the server. This FAQ will give you a solution: This is a Java applet that can help JavaScript read files from the server.

2. What is JavaScript?(What is JavaScript)

Q:What is JavaScript?

A:JavaScript is a scripting language designed to add interactivity to HTML pages. In 1995, it was first implemented by the Netscape community on Netscape Navigator 2 beta. JavaScript is different from Java language (developed by Sun Microsystem ). However, the two have good interoperability.

The JavaScript language or script is usually directly embedded in the middle of an HTML file. When the user's browser opens the HTML file, the script will be executed. (In fact, there is also server-side JavaScript, but it is beyond the scope of this FAQ .)
JavaScript is an explanatory language. This means that the script will not be compiled in advance before execution, that is, the script will not convert the system-related machine code. The user's browser interprets the script, namely, analysis and immediate execution. JavaScript is supported by the following browsers:

Netscape Navigator (starting from 2.0)

Microsoft Internet Explorer (starting from 3.0)

Other browsers/products whose manufacturers license or implement JavaScript interpreters (such as Opera and Firefox)

Therefore, most browsers of Internet users currently support JavaScript. This is also why JavaScript is one of the most popular tools for adding interactivity to webpages.

3. Features of JavaScript (JavaScript Features)

Q:What can a JavaScript program do?
A:The following list shows some typical tasks in which JavaScript plays a significant role:

Giving users more browser control

Checks the user's browser, operating system, screen size, and so on.

Execute simple computing on the client

Verify user input

Processing Date and Time

During running, the Web server is not accessed to generate HTML pages.

Below you will find some simple examples to demonstrate each task.

I. Give users more browser control

Example: Here, you can modify the background color of the page and text on the browser status bar.

 

II. Check your browser and operating system.. If needed, this capability can detect the user's browser and operating system information, allowing you to perform platform-related operations.

ExampleUsers of different browsers will receive different greetings:

III. Perform simple computing on the client.

Example: This is a JavaScript calculator. If you input an arithmetic expression, JavaScript calculates its value.

IV. Verify user input.

Example: In the above calculator, if you enter a letter instead of a number, you will get a warning: Invaid input characters!

Note: JavaScript helps the browser to perform Input Validation without wasting time on accessing the Web server. If a user makes a mistake during input, he will be prompted immediately. On the other hand, if the input information can only be verified on the server, the user has to wait for the server to respond.

V. Processing date and time.

Example1: This is a JavaScript clock.

Example 2: This script will say "Nice morning, isn' t it?" according to the current time ?" Or "Good afternoon !" Or "Wow, you are not sleep yet !?". It will also tell you the date of today.

VI. generate an HTML page during running.

Example: The directory on the left (in the original text, a directory on the left) is dynamically expanded. To view all the sub-items of an item, click the corresponding white arrow. When hiding, click the arrow.

Each time you click these arrows, the browser will generate and display a new HTML page in the left-side frame. It is because of JavaScript that this can be completed on the client, so you do not have to wait for the information to repeatedly communicate between the browser and the Web server.

Related Article

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.