From WikiEducator
Jump to: navigation, search


VmvIcon Objective.png

: JS and Images

By the end of this page you will be able to:

  • Manipulate images using JavaScript

Rotate image

 <!-- Paste this code into the HEAD section of your HTML document. -->
 <script type="text/javascript">
 var strImg = new Array("image1.png","image2.png","image3.png");
 // Change the images to your ones - remember array starts at 0
 var intImgNew = 0;
 var intImgTotal = strImg.length;
 function fnImgRotate() {
   if (intImgNew == intImgTotal) {
     intImgNew = 0;
 // set the time below for length of image display (5*1000 = 5 secs)
 setTimeout("fnImgRotate()", 5*1000);
 <!-- The following image is needed in the BODY section -->
 <img src="image1.png" name="imgRotate" />

Click here for a working version

Trouble shooting

Note that the image src needs "name" not "id"

VmvIcon References.png References

virtualMV  |  Superquick wiki guide  |  Please give me some feedback

VirtualMV/JavaScript/Images. (2022). In WikiEducator/VirtualMV wiki. Retrieved August 12, 2022, from http:    (zotero)