1. Create a script block
Program code
Copy codeThe Code is as follows:
<Script language = "JavaScript">
JavaScript code is written here
</Script>
2. Hide the script code
Program code
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
Related code will not be executed in browsers that do not support JavaScript.
3 display when the browser does not support
Program code
Copy codeThe Code is as follows:
<Noscript>
Hello to the non-JavaScript browser.
</Noscript>
4. Link an external script file
Program code
Copy codeThe Code is as follows:
<Script language = "JavaScript" src = "/" filename. js "> </script>
5. Comment the script
Program code
Copy codeThe Code is as follows:
// This is a comment
Document. write ("Hello"); // This is a comment
/*
All of this
Is a comment
*/
6. output to the browser
Program code
Copy codeThe Code is as follows:
Document. write ("<strong> Hello jb51. net </strong> ");
7. Define Variables
Program code
Copy codeThe Code is as follows:
Var myVariable = "some value ";
8 string Addition
Program code
Copy codeThe Code is as follows:
Var myString = "String1" + "String2 ";
9 string SEARCH
Program code
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
10 string replacement
Program code
Copy codeThe Code is as follows:
ThisVar. replace ("Monday", "Friday ");
11 format a string
Program code
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
12. Create an array
Program code
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
13. Sort Arrays
Program code
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
14. Split string
Program code
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
15. A warning message is displayed.
Program code
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
16 pop-up confirmation box
Program code
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
17. User-Defined Functions
Program code
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
18. Call JS Functions
Program code
Copy codeThe Code is as follows:
<A href = "#" onClick = "functionName ()"> Link text </a>
<A href = "/" javascript: functionName "()"> Link text </a>
19. Execute the function after the page is loaded.
Program code
Copy codeThe Code is as follows:
<Body onLoad = "functionName ();">
Body of the page
</Body>
20 condition judgment
Program code
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
21 specified number of cycles
Program code