How to Apply Javascript to webpages

Source: Internet
Author: User
Tags comment tag html comment

This article is also the content of my students. The focus of my courses here is not to show students how to compile JS, tell them how to apply the special effects of Javascript in other websites, that is, webpage special effects.

This section describes how to modify CSS in Zblog.

You can go to my student's blog website to see: website promotion http://www.123-seo.cn

In today's web pages, javascript is widely used, which can increase webpage interaction. Javascript simplifies regular html text segments and reduces the download time. Javascript can respond to user operations in a timely manner. Even if the submitted form is checked, you do not need to waste time submitting it to cgl for verification. The features of javascript are endless, as long as you are creative. So what is the use of javascript on Web pages? Let's talk about it in detail.
There are two ways to add Javascript to a webpage:

1. Add HTML documents directly

This is the most common method. Most web pages containing Javascript use this method, for example:

<Script language = "Javascript">

<! --

Document. writeln ("this is Javascript! Use the direct insert method! ");

//-Javascript ends -->

</Script>

In this example, we can see a new tag: <script> ...... </Script>, and <script language = "Javascript"> is used to tell the browser that this is a program written in Javascript, and the corresponding interpreter needs to be mobilized for explanation.

HTML comment tag <! -- And -->: used to remove the Javascript source code that cannot be recognized by the browser, which is very useful for browsers that do not support the Javascript language.

//-Javascript end: the double slash (/) indicates the Javascript comments, that is, the characters starting from // to the end of the line are ignored. As for the document. write () function used in the program, the text in brackets is output to the window, which will be detailed later. Note that <script> ...... </Script> is not fixed and can be included in
2. If a Javascript source file (with js extension) already exists in the reference method, you can use this reference method to improve the utilization of program code. The basic format is as follows:

<Script src = url language = "Javascript"> </script>

The Url is the address of the program file. Similarly, such statements can be placed in the HTML document header or any part of the body. If you want to implement the effect of the example in "direct insertion method", you can first create a Javascript source code file "Script. js", whose content is as follows:

Document. writeln ("this is Javascript! Use the direct insert method! ");

On the webpage, you can call the program as follows: <script src = "Script. js" language = "Javascript"> </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.