Script Categories

Graphic >>> Random Click Image.

Displays a random image when the page is loaded and each time the image is clicked.

click image to change

Step 1: Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
var rand1 = 0;
var useRand = 0;

images = new Array;
images[1] = new Image();
images[1].src = "toad.jpg";
images[2] = new Image();
images[2].src = "lizard.jpg";
images[3] = new Image();
images[3].src = "gecko.jpg";
images[4] = new Image();
images[4].src = "chameleon.jpg";

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;
//  End -->
<a onClick="swapPic();"><img name="randimg" src="toad.jpg" width="330" height="190"></a><br>
font face="Verdana" size="-2">click image to change</font>

Step 2: The script uses 4 images as part of its interface. You can create your own, or use the 4 below (resized for easier download):

(right click images, and select "Save Image As")
Upload them into the same directory as your webpage.

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.

Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!). . Bitcoin Dice - Crypto Casino