JavaScript basis (a) basic understanding

What is JavaScript

  • It is the world's most scripting languages. - - interpreted language 
  • Scripting language: no compilation, while parsing the language side directly executed at runtime.
  • Client scripting language.
  • One kind of web programming technique used to add interactive behavior to an HTML page.
  • Based on the object and event-driven interpretive scripting language embedded directly into HTML pages, interpreted by the browser to execute code, not precompiled.

JavaScript development history

  • JavaScript's official name is "ECMAScript", this standard by the ECMA organization development and maintenance
  • ECMA-262 is the official JavaScript standard 
  • This standard is based on JavaScript (Netscape) and JScript (Microsoft)
  • Netscape first introduced JavaScript in Netscape2.0
  • Microsoft IE3.0 from the beginning to provide support for client-side JavaScript, JScript and the other named

JavaScript features

  • You can use any text editor to write tools, only you need a browser can execute the program
  • Interpreted: does not compile in advance, progressive execution
  • Object-based: built a large number of ready-made objects
  • suitable: 
    • Client data calculation
    • Verify the legitimacy of the client form
    • Trigger browser event
    • Web page special effects production show

JavaScript original purpose

  • Analyzing the input client. 
    •   In response to a request for the web page can not be determined on the server side are now the client for processing. 
      •   Note: You can not put all the judges are placed on js, because the browser can disable javascript.

JavaScript now extends

  • Page effects
  • And asynchronous server interaction (ajax)
  • Server Development (nodejs)
  • The development of mobile terminals (web and app)
  • Web games

JavaScript composition

  • ECMAScript: javascipt syntax specification
  • DOM: API operation page elements
  • BOM: operating functions of the API Browser Section

script tag

   HTML scripts must be located between the <script> and </ script> tag.

  To insert JavaScript in the HTML page, use the <script> tag. <script> and </ script> JavaScript will tell where to begin and end.

  Otherwise it would not execute js script you write.

 

  Tag attributes:

  • src: import documents
  • type: the type of language provision
  • async: whether asynchronous
  • sync: synchronize 
    •   Sync: a person in accordance with the order to deal with things.
    •   Asynchronous: more than one person to perform each task.
  • defer: asynchronous
    •   The difference between async: defer such as page load to complete before execution. js async is to get it implemented.

JavaScript output

  JavaScript may output data in different ways :

  • Use window.alert () pop-up warning box. (Block shells)
  • Using document.write () method to write the contents of an HTML document. (Generated page)
  • Using innerHTML to write HTML elements. (Generated page)
  • Use console.log () is written to the browser console (console output: F12)
#1.
<script>
  alert("Hello World");
</script>
#2.
<script>
  document.write("<h1>第一天</h1>");
</script>
#3.
<script>
  document.getElementById("demo").innerHTML = "段落已修改。";
</script>
#4.
<script>
  console.log(1);
</script>

 




supplement

Web Content

  • HTML provides Web content display
  • css landscaping website
  • javascipt control the behavior of the page

A reference to the label javascript

 

 <script type="text/javascript" ></script>

 <script language="javascript" ></script>

 


  Both no different, language and type have expressed specify the scripting language is javascript (ie default scripting language is not javascript), explain in the browser will appear the same effect can be carried out using regular standard wording is:

  <script language = "javascript" type

= "text / javascript"> </ script>   However, language in this property W3C's HTML standard, is no longer recommended. So after as little as possible to use in the preparation of this property or do not use language.

 

Guess you like

Origin www.cnblogs.com/yuan1994/p/11183856.html