The birth background of Javascript--javascript

Source: Internet
Author: User

The birth background of JavaScript

In the 90 's, the European and American countries of the Web programs are increasingly popular, but at that time users are also using telephone dial-up internet access, through
Modem, the speed is only 28kb/s. And the Web program is becoming more and more abundant. In the age of no JavaScript, the form
Validation, and so on, are performed on the server side.
For example, users go to a registration page, fill in User name, password, personal information, click Register, OK, things big ...
Send the message, start the network transmission, wait more than 10 seconds, the server receives the information sent by the browser client, starts processing, and then handles
Information returned to the client browser, the user suddenly found prompt user name to fill in capital letters to start, modify, and then click Register ...
Then repeat the previous step, and finally prompt the password is too short, not safe enough. Just a simple sign-up page may cost a lot of form validation
Time, wasting bandwidth. This is unbearable for the user.
In this context, the community urgently needs a client language to solve this kind of problem. Netscape at the forefront of technology (Netscape)
Started developing a client-side scripting language.
1995 Brandon Iqiyi, who worked for Netscape, developed a scripting language called LiveScript in Netscape Explorer 2.0 in order to
Catch up with the media stir Java craze and rename it to JavaScript. From this JavaScript was born.

JavaScript standardization
Famousness, JavaScript has aroused widespread concern in society, and different versions of the JavaScript language have come out,
It was popular at the time: JavaScript in Netscape Navigator 3.0, JScript in IE, and Cenvi in
Scriptease. For programmers, if you want to develop a user-friendly web program, perhaps compatibility is a lot of work, after all
Some users have different browsers, and the embedded scripting language is not the same. The standardization of JavaScript is highlighted.
In 1997, by Sun, Microsoft, and other scientists, programmers, sat together for a meeting, and developed a ECMA-262 standard, normalized
ECMAScript the ECMAScript as the basis for JavaScript implementations from the browser's major vendors.

The composition of JavaScript
JavaScript consists of three parts, Ecmascript,bom,dom, which ECMAScript the core of JavaScript, which specifies JavaScript
variables, types, keywords, functions and other basic languages. Dom is a document manipulation object, an interface for manipulating html,xml elements, and a BOM for a browser
Object that can be accessed and manipulated by the browser window.
The ECMA262 standard defines only the ECMASCRIPTD standard for DOM. The BOM does not have a standard, and Bom,dom belongs to the host object.
The so-called host is the JavaScript operating environment, such as the browser you see now. Different browsers have a slight difference in host objects
So the most painful compatibility issues facing the front end are the BOM and DOM.

JavaScript basics
1. Case-sensitive
var A; Var A is not the same
function MyName () function myName () is not the same
2. Each line ends with a semicolon, the semicolon is optional, but in order to maintain good coding habits, we add '; '.
var a = ' Hello '
var B = ' JavaScript ';
3.JavaScript comments
Single-line comment//
Multiline comment/* begins with */end. The middle part is commented out.
var a = ' 123 ' I have been commented out and will not be executed.
/* var B = ' 123 ';
alert (b);
* * The middle part is commented out will not be executed
4.{} curly braces represent blocks of code that encapsulate a series of statements in a code block
Window.onload () =function () {
............ Statement
}
if (true) {
............ Statement
}
5 Ignore extra whitespace
var num = 1;
var num=1;
var result = 1+ 2;
var result = 1 + 2;
The first example of JavaScript
<! DOCTYPE html>
<meta charset= "UTF-8" >
<title></title>
<script>

function SayHello () {
I'm a note.
var a = "Hello, JavaScript!!!";
Alert (' I'll do it first ');
alert (a);
}
</script>
<body>
<input type= "button" value= ' Hello ' onclick= "SayHello ()"/>
</body>


JavaScript code embedding location
JavaScript code to be placed in the <script>............<script> tag
<script></script> tags can be embedded in the head or in the body
Although the above code is not a problem, but a little change, there will be problems.
We add a small feature that changes the font content based on the previous example.
To avoid the problem of not getting elements due to loading order. We're not in the body.
Embed the JS code, otherwise use the Windo.onload function to delay the JS code loading.



Improved JavaScript example SayHello
<! DOCTYPE html>
<meta charset= "UTF-8" >
<title></title>
<script>
Window.onload = function () {
document.getElementById (' P1 '). innerhtml= ' SayHello ';
}

document.getElementById (' P1 '). innerhtml= ' SayHello '; there is no error in loading order P1.
function SayHello () {
I'm a note.
var a = "Hello, JavaScript!!!";
Alert (' p1 tag already exists ');
alert (a);
}
</script>
<body>
<p id= ' P1 ' >hello,javascript</p>
<input type= "button" value= ' Hello ' onclick= "SayHello ()"/>
<script>
document.getElementById (' P1 '). innerhtml= ' SayHello ';
</script>
</body>


Limited to the length of the article, here is just a tip. Because the author's level is limited, the writing time is also very hasty,
There will inevitably be some errors or inaccuracies in the text, the wrong place to ask the reader to criticize



Say in the last words:

The BO will open a JS column, long-term update, with all the system to learn JavaScript, to make colorful JS effects.

If it is useful to you, please pay attention to it.

Friends who want to watch JS video can search for "colorful JavaScript" on 51CTO.

This article from "The Heart has the tiger, the fine smell Rose" the blog, please must keep this source http://zhangdongxu.blog.51cto.com/12029530/1955944

The birth background of Javascript--javascript

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.