Closed Thread Icon

Preserved Topic: Random Image onLoad Pages that link to <a href="https://ozoneasylum.com/backlink?for=8757" title="Pages that link to Preserved Topic: Random Image onLoad" rel="nofollow" >Preserved Topic: Random Image onLoad\

 
Author Thread
darknosis
Bipolar (III) Inmate

From: Lahore, Pakistan
Insane since: Mar 2003

posted posted 07-15-2003 11:39

Can anyone tell me a script for a random image that'll appear onLoad.

kuckus
Bipolar (III) Inmate

From: Berlin (almost)
Insane since: Dec 2001

posted posted 07-15-2003 12:28

Here's how the Doc did it at the GurusNetwork:

code:
<script type="text/javascript">
<!--DocOzone's Javascript code, copyright 2000
// Feel free to borrow and modify this code,
// but be sure to leave this credit in the source!
// Your pal, -Dr. Thaddeus Ozone-
// [url=http://www.ozones.com/]http://www.ozones.com/[/url]


// start random logo script

logonames = new Array (
"gurus_logo_ozone2.jpeg",
"gurus_logo_ozone.jpeg",
"gurus_logo_ozone4.gif"
);

rando = Math.round( Math.random() * (logonames.length - 1) )

logoname = logonames[rando];

document.write('<img src="http://gurusnetwork.com/images/logos/'+logoname+'" width="360" height="128" border="0" />');

//-->
</script>



Just add your pictures' file names to the "logonames" array and adjust the path and width/height in the <img> tag.


kuckus

darknosis
Bipolar (III) Inmate

From: Lahore, Pakistan
Insane since: Mar 2003

posted posted 07-15-2003 17:03

Ok but just for curiosity, I wrote the script like this, is it 'by far' somehow correct. My friend thinks i messed up in the URL for the images.

code:
<-- Begin
var theImages = new Array()

theImages [0] = 'assets/images/head01.gif'
theImages [1] = 'assets/images/head02.gif'
theImages [2] = 'assets/images/head03.gif'
theImages [3] = 'assets/images/head04.gif'
theImages [4] = 'assets/images/head05.gif'

var j = 0
var p = theImages.length;
var preBuffer = new Array()
far (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 src = "'+theImages[whichImage]+'">');
}
// End-->



And also one more thing, if the images are in a folder should I add the the folder name as well or just skip that??

[This message has been edited by darknosis (edited 07-15-2003).]

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 07-15-2003 17:49

That is pretty much the same thing the only thing is that as far as what you showed here, the prebuffer is not of any use and will only slow down the loading of the page.



.:[ Never resist a perfect moment ]:.

JeremyToaster
Obsessive-Compulsive (I) Inmate

From: norman, ok, usa
Insane since: Feb 2004

posted posted 02-29-2004 01:21

How do I determine the placement of the loaded image?
The script goes in the <head> but what do I put in the <body> to determine where the image is loaded?

Thanks

jeremy

JKMabry
Maniac (V) Inmate

From: out of a sleepy funk
Insane since: Aug 2000

posted posted 02-29-2004 01:26

greets to Norman, the script posted above by kuckus is self contained, you jsut place it where you want the image. The document.write bit on the last line tells the browser to 'see' the proper image tag.

JeremyToaster
Obsessive-Compulsive (I) Inmate

From: norman, ok, usa
Insane since: Feb 2004

posted posted 02-29-2004 02:06

Hey thanks, but I used Kuckus' script instead. How does that one place the image?

JKMabry
Maniac (V) Inmate

From: out of a sleepy funk
Insane since: Aug 2000

posted posted 02-29-2004 21:11

I thought Norman was a college town

Put nothing in the head, place kuckus' (Doc's) script wherever you want the image(s) to appear in the body


« BackwardsOnwards »

Show Forum Drop Down Menu