9.22 CSS compound attributes and the execution sequence of JavaScript on the HTML page

Source: Internet
Author: User

CSS Compound Effect

The effect of CSS can overlap. For example, if class = "a B" is used, the node has both the attributes of a and B, and B can overwrite the attributes of.

 

Execution sequence of Javascript in HTML

After a simple test, we found that the execution sequence of JavaScript is based on the loading sequence of JS, while the onload function is executed only after the whole page is loaded.

 

My test files:

<! -- <Br/> to change this template, choose tools | templates <br/> and open the template in the editor. <br/> --> <br/> <! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en"> <br/> <HTML> <br/> <pead> <br/> <title> </title> <br/> <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8 "> <br/> <MCE: script language =" JavaScript "type =" text/JavaScript "> <! -- <Br/> alert ("Js in the header! "); <Br/> function loadon () {<br/> alert (" onLoad! ") <Br/>}</P> <p> // --> </MCE: SCRIPT> <br/> </pead> <br/> <body onload = "loadon ()"> <br/> todo write content <br/> <MCE: script Language = "JavaScript" type = "text/JavaScript"> <! -- <Br/> alert ("before the </body>"); </P> <p> // --> </MCE: SCRIPT> <br/> </body> <br/> </ptml> <br/> 

Execution result:

 

 

We can see that:

The JS Code in the header is loaded first, so it is also executed first.

Second loading in the body

Onload is loaded after the body is fully loaded. Therefore, it is executed only after the Js in the body is executed.

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.