Script Label CharSet Property Usage Description _ Basics

Source: Internet
Author: User
Tags character set
Definitions and usage
The CharSet property stipulates the character encoding used in the external script file.

If the character encoding in the external file differs from the encoding in the main file, the CharSet attribute is used.

The default character encoding is iso-8859-1.
src and CharSet properties
For particularly long JavaScript programs or programs that are often reused, you may want to store the code in a separate file. In this case, let the browser load the individual file with the SRC attribute.

The value of SRC is the URL of the file that contains the JavaScript program. The MIME type of the saved file should be application/x-javascript, but if the filename has a suffix of. js, it can be properly handled by the server properly configured.

For example, the following statement:

<script type= "Text/javascript" src= "/w3school.com.cn/abc.js" >....</script>
The above example tells a browser that supports <script> to download a JavaScript program named Abc.js from the server.

Important: Please note that although the <script> tag has no content, the end of the </script> tag is also required.

The CharSet property is used in conjunction with the SRC attribute to tell the browser the character set used to encode the JavaScript program. Its value is the name of any one of the ISO standard character set encodings.
Instance
Define the character encoding used in the external script file:

<script type= "Text/javascript" src= "Myscripts.js" charset= "UTF-8" ></script>
Tiy
Grammar
<script charset= "Value" >
Property value
Value Description
Character_encoding the character encoding of the external script file. The common character sets are:

UTF-8-Unicode character encoding
Iso-8859-1-character encoding for Latin alphabet
To view all of the available character sets, visit our Character set reference manual.

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.