PDA

View Full Version : Timing on Image Swap


Ollie
05-03-2003, 01:34 PM
Here is the script that I want to use.....
But I am having a problem with the timing, I want the timing to be in days, I know that I need to write 1000*60*60*24 But Do I need to also write 1000*60*60*24*48 ect for the rest of the images to be swapped? If so I am not clear where to put these numbers. I am new to scripting.. but am learning. Thanks, Ollie



<!-- THREE STEPS TO INSTALL IMAGE CYCLER:

1. Copy the coding into the HEAD of your HTML document
2. Add the onLoad event handler into the BODY tag
3. Put the last coding into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Original: D. Keith Higgs (dkh2@po.cwru.edu) -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var timeDelay = 20; // change delay time in seconds
var Pix = new Array
("01.jpg"
,"02.jpg"
,"03.jpg"
,"04.jpg"
);
var howMany = Pix.length;
timeDelay *= 1000;
var PicCurrentNum = 0;
var PicCurrent = new Image();
PicCurrent.src = Pix[PicCurrentNum];
function startPix() {
setInterval("slideshow()", timeDelay);
}
function slideshow() {
PicCurrentNum++;
if (PicCurrentNum == howMany) {
PicCurrentNum = 0;
}
PicCurrent.src = Pix[PicCurrentNum];
document["ChangingPix"].src = PicCurrent.src;
}
// End -->
</script>
</HEAD>

<!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->

<BODY OnLoad="startPix()">

<!-- STEP THREE: Copy this code into the BODY of your HTML document -->

<img name="ChangingPix" src="01.jpg">

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 1.31 KB -->

beetle
05-03-2003, 02:50 PM
If you are wanting this to display a different image every couple of days -- it won't. This is a slideshow, that always starts at image 1, and plays through each consecutive image each browser session. A two day delay just means you'd have to keep the page open for two days to see the picture change.

You will need a script that observes the system date, and displays the image based on that. I'd show you myself right now but I don't have the time.

p.s. I just thought, you may actually be wanting this for an active desktop or something for yourself. Is that the case?

Ollie
05-03-2003, 03:15 PM
Thanks Beetle, BTW Are you the same Beetle that visits CMA?? Actually I wanted to learn how to swap the images for a website mascot. I thought it would be fun for my visitors to be able to watch it grow... thought it would draw intrest to the site. I know that there are others out there but I cant get to the source code to learn.. so I have to do it the hard way.. and stumble along in the dark untill I get it! Ollie

Ollie
05-03-2003, 06:04 PM
Ok, I finally found a good (I think) script to use, but now I am not sure if I should put the urls in where it says "Monday jpg" ect If this script is not what I need please tell me. Please be patient with me as I learn, I have been pulling my hair out over this for a week now! Ollie


<!-- ONE STEP TO INSTALL WEEK DAY IMAGE:

1. Copy the coding into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the BODY of your HTML document -->

<BODY>

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
today = new Date();
day = today.getDay();
arday = new Array("sunday.jpg", "monday.jpg", "tuesday.jpg",
"wednesday.jpg", "thursday.jpg", "friday.jpg", "saturday.jpg");

document.write("<img src='" + arday[day] + "'>");
// End -->
</script>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 0.63 KB -->

shlagish
05-03-2003, 06:30 PM
I think this is what you want.

And yes, the image you want displayed on sunday (sunday.gif) should be placed in the first slot of the array:
arday = new Array("sunday.gif", "monday.gif", "tuesday.gif",
"wednesday.gif", "thursday.gif", "friday.gif", "saturday.gif");
It could as well be asfkjsnvihpigausnjnsddhjfianfausfiasfhaugfaigkjadvniaugthweiuthiujcnaukizufhsaio.gif and you would still put it at the same place:
arday = new Array("asfkjsnvihpigausnjnsddhjfianfausfiasfhaugfaigkjadvniaugthweiuthiujcnaukizufhsaio.gif", "monday.gif", "tuesday.gif",
"wednesday.gif", "thursday.gif", "friday.gif", "saturday.gif");