Newsgroup: it.comp.lang.javascript
Titolo: Rotating image script

I need to set up a script to rotate a set of about 8 animated gifs. The
gifs will constantly be changing, so I need to set it up in such a way
that allows me to just change the images on my server to update all of
the 30-something reference pages that will run this script. Any ideas? I
have a java applet that allows me to do this, but it takes a while to
download and I'd prefer to set it up in javascript. Thanks in advance
for any help.
Mike O'Hara



Well, I have made a scipt sort of what you are looking like.  It will
choose a banner randomly whenever the page is loaded.  Is that what
you are needing?  If not, I may be able to write you one for your
specifics, only if I have time, which I probably will, for free.
All that I require is a link back to my site.  Let me know.


This can do what you want:
<SCRIPT LANGUAGE="JavaScript">
<!--
      tot = 7;       /*  */
      actual = parseInt(Math.random()*(tot+0.50));
      if( isNaN( actual ) )         
         actual = 0;
      document.writeln( '<IMG BORDER=0 SRC="img/home' + actual + '.jpg">' );
   // -->
</SCRIPT>
<NOSCRIPT>
      <IMG BORDER=0 SRC="img/home0.jpg">
</NOSCRIPT>
And if you insert a metatag to reload the page after x sec you have a
rolling random image loader.
This script force you to use all the same type of file ( all jpg or gif )
Bye GioP
--------------------
Giovanni Perteghella
Digital Lab - Consulenza e Formazione
mailto:
d...@sirio.com
http://www.sirio.com/dl


Hi,    Mike  
I hope that this script makes what you have asked:
----------------- begin-------------------------------------
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide for old Browsers
banner=7;
var ACTIVE=0;
var STOP=0;
var FOTO=new Array();
for (i=0;i<banner;i++){
 FOTO[i]=new Image();
}
/* Then load your own .gif file names in place of
   those shown here... */
FOTO[0].src="your_foto1.gif";
FOTO[1].src="your_foto2.gif";
FOTO[2].src="your_foto3.gif";
FOTO[3].src="your_foto4.gif";
FOTO[4].src="your_foto5.gif";
FOTO[5].src="your_foto6.gif";
FOTO[6].src="your_foto7.gif";
FOTO[7].src="your_foto8.gif";
function ROTATE(){
 if (STOP!=1){
  document.YOUR_PHOTO.src=FOTO[ACTIVE].src;
  ACTIVE++;
  if (ACTIVE>7){ACTIVE=0;}
  setTimeout("ROTATE()",5000);
  }
}
// End Hiding -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="white">
 
<TABLE>
<TR><TD>
<IMG SRC="your_foto1.gif" HEIGHT=20  WIDTH=200  NAME="YOUR_PHOTO">
</TD></TR>
</TABLE>
 
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide for old Browsers
ACTIVE=0;
setTimeout("ROTATE()",5000);
// End Hiding -->
</SCRIPT>
  <br>   
</BODY>
</HTML>
----------------- end-------------------------------------
Ciao
Pasquale Annunziata
 __/ __/ __/ __/ __/ __/ __/ __/ __/ __/ __/ __/ 
WebDesigner 
and Webmasters' Guild Member.
e-mail:  
pasq...@mclink.it
 
http://www.mclink.it/personal/MC0414
__/ __/ __/ __/ __/ __/ __/ __/ __/ __/ __/ __/ 

pasq...@mclink.it
 (Pasquale) wrote:
..

Netscape 4.03/win95b:
JavaScript Error:
file:/C|/WINDOWS/Profiles/admin/Desktop/homepage/rotate pictures.html,
line 30:
FOTO[ACTIVE] has no properties.
When ACTIVE rises to 8, the above error occurs - the problem seems to
be "ACTIVE".
 using integers instad of the variable all works right:
switch (ACTIVE){
	case 0:
	  	document.YOUR_PHOTO.src=FOTO[0].src;
		break;
... 
Any hints?
Wilhelm