JavaScript tutorials-from Getting started to mastering (1)

Source: Internet
Author: User
Tags format html page html tags implement integer variables variable window
javascript| tutorial JavaScript, which is developed by Netscape and released with the Navigator Navigator, is an object-driven programming language between Java and HTML, and is gaining worldwide attention. Because its development environment is simple, does not need the Java compiler, but runs directly in the Web browser, but because of the web designer's love.

This set of JavaScript tutorials is divided into nine chapters from a simple application of JavaScript and JavaScript to how to implement complex interactions with JavaScript, for JavaScript beginners and advanced learners, Are a rare and excellent tutorial.

JavaScript Tutorials Language Overview

The internet era has created our new work and way of life, its interconnection, openness and sharing of information mode, breaking the traditional way of information dissemination of the numerous barriers, to bring us new opportunities. With the advent of the computer and Information age, the pace of human society is gradually accelerating, every day there are new things happen every day in the creation of miracles. With the rapid development of Internet technology, all walks of life are joining the internet industry. The internet can bring limitless vitality, both from management and from a business standpoint. Through the Internet, can achieve regional, collective and even personal connection, so as to achieve a "unified harmony." Then how to add their own or the company's information resources to the WWW server, is the majority of users increasingly concerned about the problem. Using Hyper-chain technology (Hyper-text and hypermedia technology) is the simplest and quickest way to achieve this goal. The specific support environment for this means is the HTML Hypertext Markup Language. They make the Web pages you want.
The linking of hypertext (Hyper Text) and Hypermedia (Hyper Media) technology combines hyperlinks (Hyper link) to organize information into a network structure (web) that forms a network document that enables "roaming" over the Internet. Through the description of the HTML symbol can realize the text, form, sound, image, animation and other multimedia information retrieval.
However, the use of this hyper-chain technology has a certain flaw, that is, it can only provide a static information resources, the lack of dynamic client and server-side interaction. Although some interaction can be achieved through the CGI (Common Gateway Interface) Common Gateway Interface, because of the complexity of programming, this method has prevented the development of Internet technology for some time. And the advent of JavaScript, the chance for Internet users to bring the network. It can be said that the emergence of JavaScript is the demand of the times, is today's information age makes JavaScript.
The appearance of JavaScript, it can make the information and users is not only a relationship between display and browsing, but to achieve a real-time, dynamic, and the ability to express the expression. Thus, a CGI-static HTML page is replaced by a Web page that provides dynamic real-time information and responds to customer actions. JavaScript scripts are the language that is the result of satisfying this requirement. It is well received by popular users. It is an excellent one in many scripting languages, and its combination with WWW effectively realizes the blueprint of Network Computing and network computer. The non-condensed Java family will dominate the Internet network. Therefore, as soon as possible to master JavaScript scripting language programming method is the growing concern of our customers.

One, what is JavaScript

JavaScript is a scripting language that is object-based (object) and event-driven (driven) and has a secure performance. It is intended to be used with HTML Hypertext Markup Language, Java scripting language (Java applets) to link multiple objects in a Web page and interact with web customers. So that you can develop client applications, and so on. It is implemented in the standard HTML language by embedding or entering. Its appearance compensates for the HTML language flaw, it is the Java and the HTML compromise choice, has the following several basic characteristics:

  Scripting languages

JavaScript is a scripting language that uses small program segments to implement programming. Like other scripting languages, JavaScript is also an interpretive language that provides an easy development process.
Its basic structure form and C, C + +, VB, Delphi is very similar. But unlike these languages, it needs to be compiled first, and is interpreted step-by-step in the process of running a program. It is combined with HTML tags to facilitate user action.

  Object-based language

JavaScript is an object-based language that can be viewed as an object-oriented object. This means that it can use the objects that you have created. As a result, many features can be derived from the interaction of the methods and scripts of objects in the scripting environment.

  of simplicity

The simplicity of JavaScript is mainly reflected in: first of all, it is a simple and compact design based on Java basic statements and control flow, which is a very good transition for learning java. Second, its variable type is weakly typed and does not use a strict data type.

  Security

JavaScript is a security language that does not allow access to local hard disks, does not store data on the server, modifies and deletes network documents, and can only be accessed through browser or dynamic interaction. So as to effectively prevent the loss of data.

  of dynamic

JavaScript is dynamic and can respond directly to user or customer input without having to go through a Web service program. It responds to the user's response in an event-driven manner. Event-driven, which is the action generated by performing an action in the home page, is called an event. For example, press the mouse, move the window, select the menu, etc. can be considered as an event. When an event occurs, the corresponding event response may be caused.

  Cross-platform nature

JavaScript is dependent on the browser itself, regardless of the operating environment, as long as the browser can run the computer, and support JavaScript browser to execute correctly. Thus realizing the "write once, all over the world" dream.

In fact, the best thing about JavaScript is that you can do a lot of things with very small programs. No need for high-performance computers, software only need a word processing software and a browser, without the Web server channel, through their own computer can do everything.
The combination of JavaScript is a new descriptive language that can be clamped into HTML files. The JavaScript language can respond to consumer needs events such as: form, instead of using any network to transmit data back and forth, so when a user enters a piece of data, it does not have to pass through to the server to process, then pass back the process, and directly by the client ( Client) are processed by the application.
JavaScript and Java are similar, but not the same! Java is a much more complex programming language than JavaScript, and JavaScript is a language that is fairly easy to understand. JavaScript creators can be less focused on programming skills, so many Java features are not supported in Java Script.

  Two, the difference between JavaScript and Java

Although JavaScript is closely related to Java, it is a different two product developed by two companies. Java is a new generation of Sun's object-oriented programming language, especially for Internet application development, and JavaScript is the product of Netscape, the purpose of which is to extend Netscape Navigator functionality, The development of an object-oriented and event-driven interpretive language embedded in a Web page, formerly live Script, and Java's predecessor was the Oak language. The following compare the similarities and differences between the two languages as follows:

  Object based and object oriented

Java is a real object-oriented language, and even if you are developing a simple program, you must design objects.
JavaScript is a scripting language that can be used to create complex software that is unrelated to the network and interacts with the user. It is an object-based (object Based) and event-driven programming language (Driver). As a result, it provides a very rich internal object for designers to use.

  Interpretation and compilation

The two languages do not perform the same way in their browsers. Java's source code must be compiled before it is passed to the client, so that the client must have an emulator or interpreter on the platform that implements the binding of compiling code independent of a particular platform through a compiler or interpreter.
JavaScript is an interpretative programming language whose source code does not need to be compiled before it is sent to the client, but instead sends the text-formatted character code to the client for interpretation by the browser.

  Strong variables and weak variables

The variables adopted in the two languages are different.
Java uses strongly typed variables to check that all variables must be declared before they are compiled. Such as:
Integer x;
String y;
x=1234;
x=4321;
Where the x=1234 description is an integer, the y=4321 description is a string.
A variable declaration in JavaScript, using its weak type. That is, the variable does not need to be declared before it is used, but rather the interpreter checks its data type at run time, such as:
x=1234;
Y= "4321";
The former indicates that x is a numeric variable, while the latter indicates that Y is a character variable.

  Code format is not the same

Java is an HTML-independent format that must be loaded through a reference to an external media like HTML, and its code is stored in a separate document as a byte code.
JavaScript code is a text character format that can be embedded directly in an HTML document and dynamically loaded. Writing an HTML document is as easy as editing a text file.

  Different embedding methods

In HTML documents, the two programming languages have different identities, JavaScript uses <Script>...</Script> to identify, and Java uses <applet>...</applet> to identify.

  Static and dynamic joint-edit

Java uses a static binder, that is, Java object references must be made at compile time to enable the compiler to implement strong type checking.
JavaScript uses a dynamic binder, which is a JavaScript object reference that is checked at run time, and cannot be checked for object references without compilation.

  Three, JavaScript program running environment

Java Runtime Environment
Software Environment:
Windows 95/98 or Windows NT.
Netscape Navigator x.0 or Internet Explorer x.0.
A character editor (WS, WPS, Notepad, WordPad, and so on) or an HTML document editor for editing HTML documents.
Hardware configuration:
You must first have a basic hardware configuration environment running Windows 95/98 or Windows NT. Recommended:
Basic memory 32M.
CRT only needs 256 colors, resolution above 640x480.
The CPU is only less than 233.
Mouse and other external settings (selected as required).

  Iv. writing the first JavaScript program

Let's use an example to write the first JavaScript program. It shows how JavaScript scripts are embedded in HTML documents.
test1.html Documents:
<script Language = "JavaScript" >
JavaScript appears here.
Alert ("This is the first JavaScript example!");
Alert ("Welcome you into the JavaScript world!");
Alert ("We will learn about JavaScript together in the future!") ");
</Script>
</Head>
</Html>

The results of running rows in the Internet Explore5.0 are shown in Figure 1-1.

  Description: test.html is an HTML document whose identity format is in the standard HTML format; Like the HTML markup Language, JavaScript code is text that can be browsed by some word processing software, which appears in the HTML-related area of the description page.

JavaScript code consists of <script Language = "JavaScript" >...</Script> description. JavaScript scripts can be added between the identity <script Language = "JavaScript" >...</Script>.
Alert () is a JavaScript window object method that pops up a string with the OK dialog box and displays ().
Through the <!--...//--> identification Note: If you do not know the JavaScript code browser, all the tags in it are ignored, if you know, then execute its results. Using annotations This is a good programming habit that makes it possible for others to read your language.
JavaScript ends with a </Script> tag.

From the above example analysis, we can see that writing a JavaScript program is really very easy.



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.