There are three common methods for automatically executing JS functions in web pages
In the Head area in HTML, there are the following functions:
Next, we will focus on the above function and let it be loaded on the web page run automatically!
①The first method
Change the above code to:
②Second method
Modify the Body of the web page to:
Or change to:
③The third method
Use JS timer to execute functions intermittently:
setTimeout("MyAutoRun()",1000); //Execute the MyAutoRun() function every 1000 milliseconds
To implement the method, change the top JS function to:
Other methods are more special, not commonly used, and not very versatile, so I won’t introduce them!
EL& JSTL can also be used in JS
var step = "";
switch(step) {
case"0":
default:
break ; var step = "";