BounceFish 

Website Solutions
Search
      home solutions clients resources faqs contact us  
  See our portfolio under the solutions section.

Resources - For Developers

Back to Resources For Developers Homepage

===ADD THIS ONLOAD STATEMENT BELOW TO YOUR BODY STATEMENT===
<BODY OnLoad="swapPic()">
===ADD THIS ONLOAD STATEMENT ABOVE TO YOUR BODY STATEMENT===

================COPY CODE BELOW INTO BODY===========================
<SCRIPT language="JavaScript">
<!--
var rand1 = 0;
var useRand = 0;
images = new Array;
images[1] = new Image();
images[1].src = "images/image1.gif";
images[1].alt = "Picture 1";
images[2] = new Image();
images[2].src = "images/image2.gif";
images[2].alt = "Picture 2";
images[3] = new Image();
images[3].src = "images/image3.gif";
images[3].alt = "Picture 3";
images[4] = new Image();
images[4].src = "images/image4.gif";
images[4].alt = "Picture 4";
images[5] = new Image();
images[5].src = "images/image5.gif";
images[5].alt = "Picture 5";
function swapPic() {
var imgnum = images.length - 1;
do {
var randnum = Math.random();
rand1 = Math.round((imgnum - 1) * randnum) + 1;
} while (rand1 == useRand);
useRand = rand1;
document.randimg.src = images[useRand].src;
document.randimg.alt = images[useRand].alt;
}
//-->
</SCRIPT>

<IMG NAME="randimg" SRC="images/image1.gif" alt="image1">

================COPY CODE ABOVE INTO BODY===========================

    INSTRUCTIONS
  • Add the onLoad statement to your opening BODY tag
  • Paste code inside body <BODY></BODY> of HTML page

    DESCRIPTION
  • Lets you have a random image appear every time the page loads

 

Copyright © 2003-2012. BounceFish Web Design. All rights reserved.