Revolving Pictures

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was searching around for scrolling Marquee and found how to add images that
change every 3 seconds and for the life of me I can't find where it is now.
Any idea?
 
Sammyhammy said:
I was searching around for scrolling Marquee and found how to add
images that change every 3 seconds and for the life of me I can't
find where it is now. Any idea?

I am not sure how scrolling marquees relates to revolving pictures. They are
somewhat different.

Anyway, I replied to a similar query recently so, hoping it answers your
query, below is the code I posted.

This code actually use images from http://javascript.internet.com, so you
don't have to change anything to see it working.
Changes you would need to make:
1. var interval (this is in milliseconds) - you may want 3000
2. var random_display
Set to 0 to display images in the order you specified them.
Set to 1 to display images in random order.
3. The image-list entries.
e.g. image_list[image_index++] = new
imageItem("http://javascript.internet.com/img/image-cycler/01.jpg");
Alter the contents of the brackets to your images.
You can add as many as you like.
4. The width and height of the image.
It is set to 120*90, so this will only corectly display images with these
proportions.
To display a larger image, alter these parameters. If you don't know the
ratio of width to height, specify only one of width and height.

CODE HERE
<html>
<head>
<!-- Original: Robert Bui ([email protected]) -->
<!-- Web Site: http://astrogate.virtualave.net -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<script language="javascript">
var interval = 2500; // delay between rotating images (in milliseconds)
var random_display = 1; // 0 = no, 1 = yes
var image_index = 0;
image_list = new Array();
image_list[image_index++] = new
imageItem("http://javascript.internet.com/img/image-cycler/01.jpg");
image_list[image_index++] = new
imageItem("http://javascript.internet.com/img/image-cycler/02.jpg");
image_list[image_index++] = new
imageItem("http://javascript.internet.com/img/image-cycler/03.jpg");
image_list[image_index++] = new
imageItem("http://javascript.internet.com/img/image-cycler/04.jpg");
var number_of_image = image_list.length;

function imageItem(image_location) {
this.image_item = new Image();
this.image_item.src = image_location;
}
function get_ImageItemLocation(imageObj) {
return(imageObj.image_item.src)
}
function generate(x, y) {
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
}
function getNextImage() {
if (random_display) {
image_index = generate(0, number_of_image-1);
}
else {
image_index = (image_index+1) % number_of_image;
}
var new_image = get_ImageItemLocation(image_list[image_index]);
return(new_image);
}
function rotateImage(place) {
var new_image = getNextImage();
document[place].src = new_image;
document[place].title = 'image' + image_index
var recur_call = "rotateImage('"+place+"')";
setTimeout(recur_call, interval);
}
</script>
</head>
<body onload="rotateImage('rImage')">
<center>
<img name="rImage"
src="http://javascript.internet.com/img/image-cycler/01.jpg" width=120
height=90>
</center>
<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="The">http://javascriptsource.com">The JavaScript
Source</a></font>
</center><p>
</body>
</html>
 
Back
Top