JavaScript is a scripting language designed to interact with Web pages, and its composition
ECMAScript (CORE) DOM (Document Object model) BOM (Browser object model)
1.1ECMAScript
The ECMA-262 definition of Ecmascrip is not dependent on the Web browser, ECMA-262 defines only the basis of the language and provides core language features
ECMAScript is a ECMA-262 standardized scripting language that ECMA-262 language: syntax, type, statement, keyword, reserved word, operator, object
1.2 DOM (Document Object modle)
DOM is an application programming interface (Api,application programming Interface) for XML that is extensible for HTML, providing methods and interfaces for accessing and manipulating Web page content
The DOM maps the entire page to a multi-tiered node structure, and each component of the page, HTML or XML, is a type of node that contains different types of data.
1.3 BOM (Bower Object modle)
Controls other than the pages displayed by the browser, the BOM handles only browser windows and frames, and provides methods and interfaces to interact with the browser
Second, <script> elements
2.1 Referencing JavaScript files
External referencing JavaScript file:
Copy Code code as follows:
<script type= "Text/javascript" src= ". /.. /xx.js "></script>
Page embedding JavaScript code
Copy Code code as follows:
<script type= "Text/javascript" >
JavaScript code
</script>
The JavaScript code contained within the <script> element will be interpreted from top to bottom.
Properties of 2.2 <script> elements
Defer delay script: Tell the browser to download immediately, the script will be delayed until the entire page is resolved to execute, defer only for externally introduced script files
Copy Code code as follows:
<! DOCTYPE html>
<script type= "Text/javascript" defer= "defer" src= "Example.js" ></script>
Although the <script> tag is in the
Async Asynchronous Script: Must let the page wait for the script to download and execute, thus asynchronously load the page other content
As with defer only for externally introduced script files, Async told the browser to download the file immediately, but unlike defer, the markup does not async scripts do not guarantee that they are executed in the order specified, it is recommended that asynchronous scripts do not modify the DOM during load
Copy Code code as follows:
<!--asynchronous Script-->
<script type= "Text/javascript" async= "async" src= "Example1.js" ></script>
<script type= "Text/javascript" async= "async" src= "Example2.js" ></script>
Properties of 2.3 <noscript> elements
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title>test</title>
<!--delay Script-->
<scripttype= "Text/javascript" defer= "defer" src= "Example.js" ></script>
<!--guide Script-->
<script type= "Text/javascript" async= "async" src= "Example1.js" ></script>
<script type= "Text/javascript" async= "async" src= "Example2.js" ></script>
<body>
<noscript>
<p> page display requires browser support (enabled) Javascript
</noscript>
</body>
Browsers do not support scripting
The browser supports scripting, but the script is disabled and the browser displays the contents of the <noscript>
This page will display a message to the user when the script is invalid, and in a script-enabled browser, the user will never see it
The above is the entire content of this article, I hope you can enjoy, this series will continue to update.