Javascript - Display Random Images On Load

In this tutorial we will create a Display Random Images On Load using Javascript. JavaScript is a scripting or programming language that allows you to implement complex things on web pages. It is widely used in designing a stunning website. It is an interpreted programming language that has a capabilities of Object-Oriented. This code can be used as your calculator to any mathematical problem. So Let's do the coding...

Creating the Script

This code contains the script of the application. This code will render a random images to the page body. To do this just copy write the code as shown below inside the text editor and save it as script.js.

var images =[

'image 1.jpg',

'image 2.jpg',

'image 3.jpg'

];

var length = images.length;

var rand = Math.floor(length*Math.random());

document.getElementById('target').src="images/"+ images[rand];

There you have it we successfully created a Display Random Images On Load using javascript. I hope that this very simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!