OnLoad Event
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" ><html> <head> <title>Test04.html</title> <script type="Text/javascript"> varCount=5; function show(){ for(varI=0; i<count;i++) {Document.writeln ("Hello world!<br/>"); } } function show2(){Count=prompt ("Please enter the number of times:",""); Show (); }//Assign the definition of a function to a variable and call the function by calling the variable varv1= function (){Alert"Hey!" "); };//This event is triggered when the page finishes loading, onload is the event property /*window.onload=function () {//alert ("page loading complete! "); document.getElementById ("Anonymous"). Onclick=function () {alert ("anonymous function, use only once"); }; };*/ function show3(){Alert"haha"); }//Bind the show function to the OnLoad event and execute after the page has finished loading //window.onload=show3; //Bind the execution result of the show function with the onload eventWINDOW.ONLOAD=SHOW3 ();</script> </head> <body> <input type="button" value="Output Hello World" OnClick="Show2 ()"/> <br/> <input type="button" value="Call function by variable"onclick=" V1 () "/> <br/> <input type="button" value="anonymous function" id= "Anonymous" /><br/> <!--<script type= "Text/javascript" > document.getElementById ("Anonymous"). Onclick=function () { Alert ("anonymous function, use only once"); }; </script></body></html>
Javascript-onload Events