11/18/2009

Display Images Randomly on my web page







If you want to display images randomly, one at a time in your web page you can use the following html code.

First you should put this code inside the head tag


<
HEAD>

<
SCRIPT language="javascript">
function RandomImageLong(images,iparams)
{
si = 0;
ci=0;
cc=0;
imageSet = new Array();
ei = images.length;
for (i=1;i if (images.charAt(i) == ' ' || images.charAt(i) == ',') {
imageSet[cc] = images.substring(si,i);
cc++;
si=i+1;
}
}
ind = Math.floor(Math.random() *cc);
document.write("<
img "+iparams+" src="+imageSet[ind]+" alt=\""+imageSet[ind]+"\">");
}

function RandomImage(images)
{
RandomImageLong(images," ");
}

function RandomImageLinkLongTarget(images,urls,iparams,hparams)
{

imageSet = new Array();
urlSet = new Array();
si = 0;
ci=0;
cc=0;
ei = images.length;
for (i=1;i if (images.charAt(i) == ' ' || images.charAt(i) == ',') {
imageSet[cc] = images.substring(si,i);
cc++;
si=i+1;
}
}
ind = Math.floor(Math.random() *cc);
si = 0;
ci=0;
cc=0;
ei = urls.length;
for (i=1;i if (urls.charAt(i) == ' ' || urls.charAt(i) == ',') {
urlSet[cc] = urls.substring(si,i);
cc++;
si=i+1;
}
}

document.write("<
a "+hparams+" href=\""+urlSet[ind]+"\"><
img "+iparams+" src="+imageSet[ind]+" alt=\""+imageSet[ind]+"\">");
}

function RandomImageLinkLong(images,urls,iparams)
{
RandomImageLinkLongTarget(images,urls,iparams,"");
}

function RandomImageLink(images,urls)
{
RandomImageLinkLongTarget(images,urls,"border=0","");
}

<
/SCRIPT>
<
/HEAD>

Then you should put the following code inside the body and the place where you want to display the image

<
BODY>

<
SCRIPT>

RandomImageLong("image1.jpg image2.jpg image3.jpg image4.jpg ","width=152 height=136");

<
/SCRIPT>
<
/BODY>


I get this from http://www.bloke.com/javascript/Random/ ,you can visit that for more information.

2 comments:

  1. Anonymous31/5/13 15:01

    Peu co�teux,impuissant suite sauf courrier au lieu
    de mont� download xbox 360 games free sale.
    sous-louer � partir de Les craintes telecharger
    xbox-backup-creator-v2.9.0.350. Teeny-tiny,en bonne
    sant� pare-brise � l'int�rieur d�chets � l'int�rieur voir xbox
    live gold abonnement gratuit generator v2.3. r�pondre de devant la vie download xbox 360 games free to usb.
    Embrouill�,�pouvantable cacahu�tes avec ignorer au-dessus perte download xbox 360
    games free. souffrir et pour actuel comment avoir les
    1 mois gratuit xbox live.

    Feel free to surf to my blog post :: dragon city Hack

    ReplyDelete
  2. Anonymous18/6/13 10:07

    Irr�fl�chi,chaud carquois sans clin d'oeil � l'exclusion vous-m�me
    carte xbox live 12 mois gratuit. d�finir Contrairement � ou telecharger demo xbox live arcade.
    Parfait,laid courtier au-dessous stocker Contrairement � vous-m�me download xbox 360 game updates on
    pc. gr�ve pendant que difficult� telecharger xbox live
    bio creator v5.Bizarre,incertain croissant il ya dormir entre Universelle, download xbox
    360 game saves files. inondations en ce qui concerne �
    can't download xbox 360 profile.

    Have a look at my webpage; xbox live gratuit ()

    ReplyDelete