jsLoading execution sequence in html
1. Loading sequence: introduce the order of appearance of the tag ,
# on the page ##JavascriptThe code is part of the HTML document, so the order in which Javascript is executed when the page is loaded is the order in which the introduction tags appear,
In this way, the order of output values under IE and other browsers is consistent. : 1, 2, I am 1, 3
: Under IE, when using the Document.Write method to reference the js file, the js file will appear to have not been loaded. In the case of direct call, it is recommended to place the referenced JS file in a separate script block. To ensure that the referenced js file is fully loaded, continue to execute the subsequent Document.Write content5. JS function execution sequence with the same name
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <script type="text/javascript"> function aa() { alert('First aa') } </script> <title></title> </head> <body> <form id="form1" runat="server"> <br /> <input id="Button1" type="button" value="button" onclick="aa();"/> </form> </body> <script type="text/javascript"> function aa(s) { alert('Second aa'); } function aa(s) { alert('Last aa'); } </script> </html>
Click "botton" to execute the result: Last aa
After a function with the same name appears in js, after you call the js function in the web page, the last loaded function in the page will always be called.
The above is the detailed content of Detailed explanation of js loading and execution order in html. For more information, please follow other related articles on the PHP Chinese website!