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.