script for onload a new image appears?

R

ross

I am looking for a script that will make a new image appear on page when
refresh or reload appears. Here is an example of such a page
http://www.vanderbilt.edu/
Thanks, I really appreciate this newsgroup. Dick Ross
 
J

J Briggs

I am looking for a script that will make a new image appear on page when
refresh or reload appears. Here is an example of such a page
http://www.vanderbilt.edu/
Thanks, I really appreciate this newsgroup. Dick Ross

This will use client-side processing to obtain a random picture.

To begin with, make a folder in your webpage folder (eg "pics") and
the possible pictures you want in there, naming them pic01.jpg,
pic02.jpg, pic03.jpg etc. The script assumes that you are using *.jpg
format for your pictures.

<script language="JavaScript">
function ChooseImage() {
var pics="10"; //REPLACE THIS WITH THE NO OF PICS YOU HAVE
var num;
var path;
num = Math.round(Math.random() * pics) + 1;
path = "pics/pic" + num + ".jpg"
document.write('<img src="' + path + '" name="Picture "' + num
+ '">');
}
</script>

Then put this where you want to put the image:

<script language="JavaScript">
ChooseImage;
</script>


Jonathan.
 
R

ross

So the first <script > goes into the header and the second <script> goes
into the body ("where youwant to put the image")? I thank you for your help.
Dick
 
J

J Briggs

So the first <script > goes into the header and the second <script> goes
into the body ("where youwant to put the image")?

Yes, that's right. The second script goes where ever you want the
random image to appear in the body.
 
R

ross

I really thank you, but I guess the ludite in me is standing in the way of
understanding this. Thanks anyway, I appreciate your time. Dick Ross
www.rosmd.com
 
M

Mark Parnell

Sometime around Wed, 05 Nov 2003 17:35:15 +0000, J Briggs is reported to
have stated:
This will use client-side processing to obtain a random picture.
Then put this where you want to put the image:

....and realise that you should have done it with a server-side script,
because ~15% of your visitors won't see the images at all. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top