hello guys, is there any one good enough to tell me how to show random pics in a frame each time my home page is loaded. i would appreciate if you tell me how to do it either in javascript or php. thanks a million times

9 Years
Discussion Span
Last Post by mehdighobakhloo

Load this as your framed page, and be sure that you provide valid path and filename with your images or this will not work...

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Random Images with frame</title>
<base target="_self" />
<script type="text/javascript">

function randomPic()
var img = (document.all) ? document.all.myImage : document.getElementById('myImage');

var pic = [];
//The valid path and filename of your images that you wish to randomize must be declared here.

pic[0] = new Image();
pic[0].src = 'image1.jpg';
pic[1] = new Image();
pic[1].src = 'image2.jpg';
pic[2] = new Image();
pic[2].src = 'image1.jpg';
 for ( var x = 0; x <= pic.length; x++ ) { 
if (document.images && img) { img.src =pic[Math.floor(Math.random()*x)].src; } } }
window.onload = randomPic;
<div id="wrapper">
<img src="image.jpg" alt="Default Image" id="myImage" width="640" height="480" />
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.