window onload 例項 【2018.11.27】
阿新 • • 發佈:2018-11-29
<html> <head> <title>window.onload</title> <script type="text/javascript"> window.onload = function(){ setInterval(step,1000); } var num=1; function step(){ if(num < 5){ num++; }else{ num = 1; } var dom = document.getElementById("imgId"); // dom.src = num + '.jpg'; } </script> </head> <body> <img src="1.jpg" width="500" height="500" id="imgId"/> </body> </html>