Distinguish between type= "Text/javascript" and language= "JavaScript" in script

Source: Internet
Author: User

Content Summary

When making a Web page, it is often necessary to use the JS code that the client can run on the page, so you need to add a reference. JS reference generally have type= "Text/javascript" and language= "JavaScript" two ways, but language this attribute in the HTML standard, is no longer recommended to use.

Specific instructions

In general, the JS reference method is:

Section ①

<script language= "Javascript" ></script>

Section ②

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

So, what is the difference between the two references?

Insert JavaScript statements in HTML pages and use HTML <script>. <script> This tag has a property called type,type= "Text/javascript", which means that inserting <script> </script>; its internal code is a JavaScript statement.

Like what:

<script type= "Text/javascript" >

document.write ("Welcome to www.yiqixue.net!");

</script>

But when referring to someone else's JavaScript code, you see that <script> is not type= "Text/javascript", but language= "JavaScript".

Both of these methods can now be used to indicate that the code in <script> </script> is JavaScript. However, the language attribute is no longer recommended in the HTML standard of the user.

Although these two references are not wrong, but in the future when we make Web pages, we should use the ② method, as little as possible to use or discard the ① method.

Distinguish between type= "Text/javascript" and language= "JavaScript" in script

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.