random image javascript

Scott Manila-Newbies@userland.com
Sun, 15 Dec 2002 08:51:03 -0800


Thanks Ryan,
It worked beautifully.
Scott

>Hi Scott -
>
>Finally - one that I can handle...  Here is the script that we use on our
>site (http://www.levistable.com - go to any of the inner pages and see the
>script working on the left-side image.)  Simply pick the images that you
>want and insert their paths into the script below.  Put this into the
>Javascripts textbox in Prefs > Advanced.
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
><SCRIPT LANGUAGE="JavaScript">
><!-- Begin
>// Set up the image files to be used.
>var theImages = new Array() // do not change this
>// To add more image files, continue with the
>// pattern below, adding to the array.
>
>theImages[0] =
>'http://66.221.37.206/pictures/createASite/youngwomantattoo.jpg'
>theImages[1] =
>'http://66.221.37.206/pictures/createASite/womanlookingatheaven.jpg'
>theImages[2] = 'http://66.221.37.206/pictures/createASite/wateronhead.jpg'
>theImages[3] = 'http://66.221.37.206/pictures/createASite/manpraying.jpg'
>theImages[4] = 'http://66.221.37.206/pictures/createASite/indian.jpg'
>theImages[5] = 'http://66.221.37.206/pictures/createASite/closeupman.jpg'
>theImages[6] = 'http://66.221.37.206/pictures/createASite/closedeyes.jpg'
>theImages[7] = 'http://66.221.37.206/pictures/createASite/bigblackman.jpg'
>theImages[8] = 'http://66.221.37.206/pictures/createASite/baby.jpg'
>theImages[9] = 'http://66.221.37.206/pictures/createASite/asianman.jpg'
>
>
>// do not edit anything below this line
>
>var j = 0
>var p = theImages.length;
>var preBuffer = new Array()
>for (i = 0; i < p; i++){
>   preBuffer[i] = new Image()
>   preBuffer[i].src = theImages[i]
>}
>var whichImage = Math.round(Math.random()*(p-1));
>function showImage(){
>document.write('<img border="1" src="'+theImages[whichImage]+'">');
>}
>
>//  End -->
></script>
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
>In your Template, simply insert this code to call the script:
>
>>>>>>>>>>>>>>>>>
>
><SCRIPT LANGUAGE="JavaScript">
><!-- Begin
>showImage();
>//  End -->
></script>
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
>Obviously, you will also need to place your {javascript} macro in the top of
>your template.
>
>Hope that helps.
>
>Thanks,
>
>Ryan Hale
>636.561.3403
>ryan.hale@levistable.com
>
>http://www.seventytwo.org
>http://www.ryanjhale.com
>http://www.levistable.com
>
>
>-----Original Message-----
>From: manila-newbies-admin@userland.com
>[mailto:manila-newbies-admin@userland.com]On Behalf Of Scott
>Sent: Sunday, December 15, 2002 1:04 AM
>To: manila-newbies@userland.com
>Subject: random image javascript
>
>
>Does anyone have a random image javascript that will work with Manila?
>
>I have not been successful adapting a javascript that works in normal html
>pages to the Manila environment. I'm having problems knowing how to
>reference the images in the script and how to call the script on a
>particular page.
>
>It would help to see how someone has accomplished this in Manila.
>
>thanks
>Scott