random image javascript

Ryan Hale Manila-Newbies@userland.com
Sun, 15 Dec 2002 00:10:18 -0500

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.


<!-- 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] =
theImages[1] =
theImages[2] = ''
theImages[3] = ''
theImages[4] = ''
theImages[5] = ''
theImages[6] = ''
theImages[7] = ''
theImages[8] = ''
theImages[9] = ''

// 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 -->


In your Template, simply insert this code to call the script:


<!-- Begin
//  End -->


Obviously, you will also need to place your {javascript} macro in the top of
your template.

Hope that helps.


Ryan Hale


-----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.