Random Image Script

This is how you can make a random image/button script.

Example

The HTML and JavaScript

This going into the BODY of your webpage (in between <body> and </body> tags). This includes the JavaScript in one chunk, too!

<script type="text/javascript">
var total_images = 4;
var random_number = Math.floor((Math.random()*total_images));
var random_img = new Array();
random_img[0] = '<a href="page1.html"><img alt="" src="https://i.postimg.cc/gJF2sXF5/88x31_anim3.gif"></a>';
random_img[1] = '<a href="page2.html"><img alt="" src="https://i.postimg.cc/DZkw6JkM/88x31_anim4.gif"></a>';
random_img[2] = '<a href="page3.html"><img alt="" src="https://i.postimg.cc/50d2gYdr/88x31_static.png"></a>';
random_img[3] = '<a href="page3.html"><img alt="" src="https://i.postimg.cc/qRVvwhVZ/88x31_static2.png"></a>';
document.write(random_img[random_number]);
</script>

<p>
just be sure to change the total_image = #; to reflect the number of random_img[#] (0 counts as one)<br>
<a href="javascript:window.location.reload(true)">Reload example</a>
</p>

Be sure to alter the # of images in the script (var total_images = 4;) to reflect how many images you plan to list!