Java rotating image script

M

mikeoley

Why would this script below work on an html page:
http://www.eg-designdev.com/aircylinders/test.htm
But not a java page such as this:
"http://www.eg-designdev.com/aircylinders/index3.jsp"

Or does anybody have a simple slide show rotation script they could
refer me to...thanks.


<HTML><HEAD>
<TITLE>Slideshow Tutorial</TITLE>

<SCRIPT LANGUAGE="JavaScript">
<!-- Beginning of JavaScript -

var timer = null
var counter =1

function slideshow() {
timer=setTimeout("slideshow()", 2000);
counter++;

if (counter >= 6)
counter = 2;
document.pictures.src = pic[counter].src;
}


function endtimer() {
clearTimeout(timer);
document.pictures.src = pic[1].src;
counter = 1;
}

// - End of JavaScript - -->
</SCRIPT>
</HEAD>

<BODY BACKGROUND="FFFFFF">

<SCRIPT LANGUAGE="JavaScript">
<!-- Beginning of JavaScript -

if (document.images) {

pic = new Array()

pic[1] = new Image(108, 108);
pic[1].src = "pic1.gif";

pic[2] = new Image(108, 108);
pic[2].src = "pic2.gif";

pic[3] = new Image(108, 108);
pic[3].src = "pic3.gif";

pic[4] = new Image(108, 108);
pic[4].src = "pic4.gif";

pic[5] = new Image(108, 108);
pic[5].src = "pic5.gif";
}

// - End of JavaScript - -->
</SCRIPT>

<CENTER>


<TABLE BORDER=0 CELLSPACING="0" CELLPADDING="0">
<TR></TR>

<TR>
<TD><IMG SRC="images/main-nrseries.gif" WIDTH="550" HEIGHT="245"
NAME="pictures"></TD>

</body>
</html>
 
M

mikeoley

Would that be the reason? I'm working on getting it turned on, but the
guy is taking forever for some reason.
 
E

Evertjan.

wrote on 24 okt 2005 in comp.lang.javascript:
Would that be the reason? I'm working on getting it turned on, but the
guy is taking forever for some reason.

Which guy?

[please do quote on usenet, others should be able to follow threads on
usenet]

Why would you want to use a jsp extention?
Javascript has nothing to do with jsp or java.
 
M

mikeoley

Why would you want to use a jsp extention?
Javascript has nothing to do with jsp or java.

I didn't build this site, I'm cleaning up someones mess. I wouldn't use
a jsp extension but it's already there. I know Javascript has nothing
to do with jsp that's why I was thrown off by it. I have found
something that worked though and now all I need to know is how to
define an array to link the images I have in my gallery.

{
pic1= new Image(550,245);
pic1.src="images/main-nrseries.gif";
pic2= new Image(pic_width,pic_height);
pic2.src="images/main-enseries.gif";
pic3= new Image(pic_width,pic_height);
pic3.src="images/main-evseries.gif";
pic4= new Image(pic_width,pic_height);
pic4.src="images/main-mciseries.gif";
pic5= new Image(pic_width,pic_height);
pic5.src="images/main-enlseries.gif";
pic6= new Image(pic_width,pic_height);
pic6.src="images/main-ensseries.gif";
}

/* define text for image captions */

var pics= new Array(6)
pics[0]=pic1.src;
pics[1]=pic2.src;
pics[2]=pic3.src;
pics[3]=pic4.src;
pics[4]=pic5.src;
pics[5]=pic6.src;
 
M

mikeoley

Ok I know have two problems.
1. Like I stated above, I'm not sure how to define an array to link
these images in the slideshow.
2. The slideshow only go through once then just stops.

Here's the code:

<script type="text/javascript">
<!--
/* define image width and height */

var pic_width=550;
var pic_height=245;

/* define image urls */

if (document.images)
{
pic1= new Image(550,245);
pic1.src="images/main-nrseries.gif";
pic2= new Image(pic_width,pic_height);
pic2.src="images/main-enseries.gif";
pic3= new Image(pic_width,pic_height);
pic3.src="images/main-evseries.gif";
pic4= new Image(pic_width,pic_height);
pic4.src="images/main-mciseries.gif";
pic5= new Image(pic_width,pic_height);
pic5.src="images/main-enlseries.gif";
pic6= new Image(pic_width,pic_height);
pic6.src="images/main-ensseries.gif";
}

/* define text for image captions */

var pics= new Array(6)
pics[0]=pic1.src;
pics[1]=pic2.src;
pics[2]=pic3.src;
pics[3]=pic4.src;
pics[4]=pic5.src;
pics[5]=pic6.src;

var numpics=6;
var thenum=0;
imgName="img1";

function change_it()
{
if (document.images)
{
document.write("<img src='"+pics[thenum]+"' border='0'
width='"+pic_width+"' height='"+pic_height+"' name='img1'>\n");
setTimeout('change_it2()',4000);
}
}

function change_it2()
{
var x=0;
thenum+=1;

if (thenum>numpics-1)
{
document[imgName].src=pics[0];
document.form1.text1.value="The End";
}
else
{
document[imgName].src=pics[thenum];

x+=1;
setTimeout('change_it2()',4000);
}
}
//-->
</script>
 
E

Evertjan.

wrote on 24 okt 2005 in comp.lang.javascript:
Ok I know have two problems.
1. Like I stated above, I'm not sure how to define an array to link
these images in the slideshow.
2. The slideshow only go through once then just stops.

Here's the code:

this <!-- is not needed since 6 years

var pic_width = 550;
var pic_height = 245;
var pic = new Array();
var n = 0;

pic[n] = new Image(pic_width,pic_height);
pic[n++].src = "images/main-nrseries.gif"; // preloading
pic[n] = new Image(pic_width,pic_height);
pic[n++].src = "images/main-enseries.gif";
pic[n] = new Image(pic_width,pic_height);
pic[n++].src = "images/main-evseries.gif";
pic[n] = new Image(pic_width,pic_height);
pic[n++].src = "images/main-mciseries.gif";
pic[n] = new Image(pic_width,pic_height);
pic[n++].src = "images/main-enlseries.gif";
pic[n] = new Image(pic_width,pic_height);
pic[n++].src = "images/main-ensseries.gif";

var numpics = n;
var img1 = document,getElementById('img1');
n = 0; // reuse as counter

function show(){
img1.src = pic[n].src; // show the img
n++; // increment pointer
if (n == numpics) n = 0; // rotating if last img
set.timeout(show(),20000); // 20 seconds/img
};
</script>

<body onload='show();'>

<img src='..' id=img1>
 
M

mikeoley

Ok one more question. I have this slideshow working now. I just need to
link the images in the slideshow to different pages in the site. How do
i do this? Do I define a new array for links I'm assuming?

{
pic1= new Image(550,245);
pic1.src="images/main-nrseries.gif";
pic2= new Image(550,245);
pic2.src="images/main-enseries.gif";
pic3= new Image(550,245);
pic3.src="images/main-evseries.gif";
pic4= new Image(550,245);
pic4.src="images/main-mciseries.gif";
pic5= new Image(550,245);
pic5.src="images/main-enlseries.gif";
pic6= new Image(550,245);
pic6.src="images/main-ensseries.gif";
}

/* define text for image captions */

var pics= new Array(6)
pics[0]=pic1.src;
pics[1]=pic2.src;
pics[2]=pic3.src;
pics[3]=pic4.src;
pics[4]=pic5.src;
pics[5]=pic5.src;
 
E

Evertjan.

wrote on 24 okt 2005 in comp.lang.javascript:
Ok one more question. I have this slideshow working now. I just need to
link the images in the slideshow to different pages in the site. How do
i do this? Do I define a new array for links I'm assuming?

Please quote, this is not email, others want to read too.

==============
Something like this?


<style>img {cursor:hand;pointer:hand;}</style>

.....................

var alink = new Array()

..................

pic[n] = new Image(pic_width,pic_height);
alink[n] = 'http://cnn.com/'
pic[n++].src = "images/main-ensseries.gif";

..................

function show(){
img1.src = pic[n].src;
img1.onclick = 'location.href='+alink[n]
n++;
if (n == numpics) n = 0;
set.timeout(show(),20000);
};
</script>

<body onload='show();'>

<img src='..' id=img1>
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Tue, 25
Oct 2005 19:48:28, seen in Evertjan.
Dr John Stockton wrote on 25 okt 2005 in comp.lang.javascript:


setTimeout("show()", 2e4) // !

I think it's worth the extra character to have the time in seconds
visible directly.
 
E

Evertjan.

Dr John Stockton wrote on 26 okt 2005 in comp.lang.javascript:
JRS: In article <[email protected]>, dated Tue, 25
Oct 2005 19:48:28, seen in Evertjan.


I think it's worth the extra character to have the time in seconds
visible directly.

I knew you would say that!
 

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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top