Js execution sequence on the page

Source: Internet
Author: User

The following is the test code:
Copy codeThe Code is as follows:
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<Head runat = "server">
<Title> execution sequence of test js </title>
<Script language = "javascript" type = "text/javascript"> <! --
Var a = "this is a piece of JS code in the Header ";
Alert ();
// --> </Script>
</Head>
<Body onload = "javscript: alert ('This is the code in the Onload event of the body! '); ">
<Form id = "form1" runat = "server">
<Div>
<P> test the js execution sequence.
</P>
</Div>
</Form>
<Script language = "javascript" type = "text/javascript"> <! --
Var a = "this is the final JS Code of a page ";
Alert ();
// --> </Script>
</Body>
</Html>

The execution sequence after running is as follows:

The execution sequence is: js in the head, js in the page (put this segment of Js outside the body tag in this order), js in the onload event of the body Tag.

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.