Learning Notes (-) using JavaScript in HTML

Source: Internet
Author: User

1.<script> Label Use

The main way to insert Javscript in an HTML page is to use the <script> tag. The script can be in the <body> or

All of the Javscript scripts contained in the

When multiple <script> tags are included, they are parsed sequentially in the order in which the <script> tags appear in the page.

There are two ways to use <script> Tags: embed JavaScript code directly on the page and include external JavaScript code

Save the script to an external file, and the file extension of the external JavaScript file is. js. To use an external file, set the. js file in the "src" attribute of the <script> tag:

<script src= "Myscript.js" ></script>

The defer property of the 2.<script> tag:

With the defer= ' defer ' attribute, the script is deferred until the entire page has been executed, and the deferred script is always executed in the order specified, and the script for the first show executes before the second deferred script. The Defer property applies only to external script files.

The async attribute of the 3.<script> tag:

The async attribute is also applied only to external script files, and the purpose of specifying the async attribute is to not allow the page to wait for the script to be downloaded and executed, thus loading the page's other content asynchronously . However, there is no guarantee that asynchronous scripts execute in the order in which they are executed in the page.

4. Document mode

Document mode: The HTML document pattern is specified by using the document type DOCTYPE. DOCTYPE is a shorthand for document type, which is used in pages to specify the version of XHTML (or HTML) used by the page. There are currently three types of document modes: Promiscuous mode (quirks modes), standard (standards mode) and quasi-standard mode. For quasi-standard mode, it is usually triggered by transition type (transitional) and frame set (frameset).

In quasi-standard mode, the feature will be parsed according to the browser standard (not all, of course, not all), the default is promiscuous mode if the document type declaration is not found at the beginning of the document. Promiscuous mode is not recommended, most of the sites are now in standard mode.

In HTML5, the document type is unified, and the direct notation is <! DOCTYPE html> can be.

Trigger Standard mode:
<!--HTML 4.01 Strict--
<! DOCTYPE HTML Public "-//w3c//dtd html4.01//en" "Http://www.w3.org/TR/html4/strict.dtd" >
<!--XHTML 1.0 Strict--
<! DOCTYPE htmlpublic "-//w3c//dtd XHTML 1.0strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >

Trigger quasi-standard mode:
<!--HTML 4.01 Transitions--
<! DOCTYPE htmlpublic "-//w3c//dtd HTML 4.01transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
<!--HTML 4.01 Frameset---
<! DOCTYPE htmlpublic "-//w3c//dtd HTML 4.01frameset//en" "Http://www.w3.org/TR/html4/frameset.dtd" >
<!--XHTML 1.0 transitions--
<! DOCTYPE htmlpublic "-//w3c//dtd XHTML 1.0transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<!--XHTML 1.0 Framework Set--
<! DOCTYPE htmlpublic "-//w3c//dtd XHTML 1.0frameset//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd" >

5.<noscript> elements

The <noscript> element is used to define alternative content (text) when the script is not executed. If the browser supports scripting, it does not display the text in the NoScript element.

Learning Notes (-) using JavaScript in HTML

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.