14-3.txt

来自「Javascript语言开发经典教程开发」· 文本 代码 · 共 33 行

TXT
33
字号
<!-- The image that will be animated. Give it a name for convenience. --><IMG SRC="images/0.gif" NAME=animation><SCRIPT>// Create a bunch of off-screen images, and get them started // loading the images we're going to animate.var images = new Array(10);for(var i = 0; i < 10; i++) {    images[i] = new Image();                 // Create an Image object.    images[i].src = "images/" + i + ".gif";  // Tell it what URL to load.}// Later, when we want to perform our animation, we can use these URLs,// knowing that they've been loaded into the cache. Note that we perform// the animation by assigning the URL, not the Image object itself.// Also note that we call the image by name, rather than as document.images[0].function animate(){    document.animation.src = images[frame].src;    frame = (frame + 1)%10;    timeout_id = setTimeout("animate()", 250);  // Display next frame later.}var frame = 0;         // Keep track of what frame of the animation we're on.var timeout_id = null; // This allows us to stop the animation.</SCRIPT><FORM>                   <!-- Buttons to control the animation. -->  <INPUT TYPE=button VALUE="Start" 	 onClick="if (timeout_id == null) animate()">  <INPUT TYPE=button VALUE="Stop" 	 onClick="if (timeout_id) clearTimeout(timeout_id); timeout_id=null;"></FORM>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?