JS study notes

JS today to start learning grammar, recording some of the more critical point, do the right notes.

Script

 JS Script tags to embed the code directly in the page and contains external JS files.

1. JS code contained in the <script> tag is interpreted sequentially from top to bottom;

2. Define the src attribute <script> tag should not contain JS code, the embedded code will be ignored;

3. The tag includes six attributes: the async (Download scripts) , charset (character set), the defer (indicate whether the script is delayed until the document is completely parsed and displayed after execution) , Language (obsolete, scripting language), src ( external file) , type (the MIME type), wherein the italic attribute is valid only for the external file.

 4.defer property requires script execute scripts in the order they appear (reference);

5.async does not guarantee the execution of the script in the order they appear script (reference);

 6. The label can be used to separate the different blocks of code, the execution code block order, scopes are global scope, can be shared variables and functions

7. Page initialization events: window.onload will respond only loaded in the document.

8. The dynamic scenario: using document.write () method of dynamic output js script and executed after the completion of all of the output, but js script inside the script tag must be placed

Guess you like

Origin www.cnblogs.com/minnong/p/11281665.html