Website creation (III)-where to place Javascript

Source: Internet
Author: User
Document directory
  • Scripts in the head section:
  • Scripts in the body section:
  • Scripts in the body and head sections:
Where to place Javascript

The script on the page will be executed immediately after the page is loaded into the browser. We don't always want this. Sometimes, we want to execute the script when the page is loaded, and in other cases, we want the script to be executed only when the user triggers the event.

Scripts in the head section:

When a script is called or an event is triggered, the script is executed. After you place the script in the head part, you can ensure that it has been loaded before you need to use the script.

Scripts in the body section:

The script is executed when the page is loaded. After you place the script in the body, it will generate the page content.

Scripts in the body and head sections:

You can place any number of scripts in the document, so you can place the script both to the body and to the head part.

The content I picked on W3 above is simple and clear, which is helpful for beginners. Therefore, you can add it to your blog.

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.