JavaScript Getting Started Tutorial two using JavaScript in HTML

Source: Internet
Author: User

There are two ways to use <script> elements: embed JavaScript code directly in the page and reference external JavaScript files.

Second, the use of embedded methods, the general wording is:

<script type= "Text/javascript" >

/* Code */

  </script>

Third, the general wording of the reference external JavaScript file is:

<script type= "Text/javascript" src= "" ></script> (note that you should not add extra in the middle of <script> and </script> tags JavaScript code. If it is included, it is ignored. )

Iv. in comparison with external references, external references are maintainable and cacheable, so it is recommended that external references be used.

Five, the location of the label storage. <script> tags can be placed anywhere in

Example:

<script type= "Text/javascript" src= "" ></script>

Or

<body>

<!--content here--

<script type= "Text/javascript" src= "" ></script>

<body>

For performance and optimization of front-end pages, the second position is undoubtedly better.

VI. <noscript> is available for browsers that do not support Javsscript or disable JavaScript. The content in,<noscript> will only be present if one of the two cases occurs.

For example:

<title> examples </title>
<body>

<!--content here--

<script type= "Text/javascript" src= "" ></script>

<noscript>
<p> This page requires browser support (enabled) JavaScript.
</noscript>

</body>

      

JavaScript Getting Started Tutorial two using JavaScript in HTML

Related Article

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.