Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
February 09, 2012, 07:18:41 PM

Pages: [1]   Go Down
  Print  
Author Topic: Script for showing images randomly.Very good.  (Read 447 times)
Bluelight
Jedi
*****
Offline Offline

Posts: 836


« on: August 26, 2001, 04:02:00 PM »

This is the code to randomly pick an image to place on a page, instead of being limited to a single image. The text in blue within the code should be changed based on your images.

<script language="JavaScript">
<!-- Hide this script from old browsers --

images = new Array();
images[0] = "images/IMAGE1NAME.gif"
images[1] = "images/IMAGE2NAME.jpg"
images[2] = "images/IMAGE3NAME.jpg"
images[3] = "images/IMAGE4NAME.gif"
images[4] = "images/IMAGE5NAME.gif"
images[5] = "images/IMAGE6NAME.gif"
images[6] = "images/IMAGE7NAME.jpg"
images[7] = "images/IMAGE8NAME.jpg"
images[8] = "images/IMAGE9NAME.jpg"

//More images can be added following the same format.
//The script will automatically adapt for more images.


function RandElement(IList)
{
    return(IList[Math.round(Math.random()*(IList.length-1))]);
}

// -- End Hiding Here -->
</script>

******************************************************************************

Place the following in your HTML in place of the normal <IMG SRC="XXXXX"> tag.

******************************************************************************

<SCRIPT>
<!-- Hide me

document.write("<IMG SRC="+RandElement(images)+">");

//-->
</SCRIPT>
 

  The other ones i was given didn`t work well for my needs but this one is very good.

      Blue
Logged
Ice
Galactic Royalty
*****
Offline Offline

Posts: 259


WWW
« Reply #1 on: August 31, 2001, 01:51:00 PM »

Thanks for sharing, Blue  

Might come in handy 1 day.  
Logged

Flipside Gin
A site for Cases ladder gin players at Flipside.com
 http://www.lunarpages.com/fsgin
Bluelight
Jedi
*****
Offline Offline

Posts: 836


« Reply #2 on: September 01, 2001, 02:29:00 AM »

Im using this script on my startpage.With it the startpage shows a different pic when you come to the site and you can add as many pic`s as you want.I only have two at the moment but i`ll add more as i get new one i like.

   See ya Ice
       
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: