By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,687 Members | 2,046 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,687 IT Pros & Developers. It's quick & easy.

Java rotating image script

P: n/a
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>

Oct 24 '05 #1
Share this Question
Share on Google+
14 Replies


P: n/a
wrote on 24 okt 2005 in comp.lang.javascript:
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"


Because your server is not a jsp enabled server?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 24 '05 #2

P: n/a
Would that be the reason? I'm working on getting it turned on, but the
guy is taking forever for some reason.

Oct 24 '05 #3

P: n/a
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.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 24 '05 #4

P: n/a
>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;

Oct 24 '05 #5

P: n/a
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>

Oct 24 '05 #6

P: n/a
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:

<script type="text/javascript">
<!--

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>

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 24 '05 #7

P: n/a
Evertjan. wrote on 24 okt 2005 in comp.lang.javascript:
set.timeout(show(),20000); // 20 seconds/img


setTimeout()

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 24 '05 #8

P: n/a
Thank you. As you can tell I'm new to this. I appreciate it.

Oct 24 '05 #9

P: n/a
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;

Oct 24 '05 #10

P: n/a
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>
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 24 '05 #11

P: n/a
JRS: In article <Xn********************@194.109.133.242>, dated Mon, 24
Oct 2005 18:09:09, seen in news:comp.lang.javascript, Evertjan.
<ex**************@interxnl.net> posted :
Evertjan. wrote on 24 okt 2005 in comp.lang.javascript:
set.timeout(show(),20000); // 20 seconds/img


setTimeout()


setTimeout("show()", 20e3) // ?
--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
The Big-8 newsgroup management is attempting to legitimise its questionable
practices while retaining its elitist hegemony. Read <URL:news:news.groups>.
Oct 25 '05 #12

P: n/a
Dr John Stockton wrote on 25 okt 2005 in comp.lang.javascript:
setTimeout("show()", 20e3) // ?


setTimeout("show()", 2e4) // !
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 25 '05 #13

P: n/a
JRS: In article <Xn********************@194.109.133.242>, dated Tue, 25
Oct 2005 19:48:28, seen in news:comp.lang.javascript, Evertjan.
<ex**************@interxnl.net> posted :
Dr John Stockton wrote on 25 okt 2005 in comp.lang.javascript:
setTimeout("show()", 20e3) // ?


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


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

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Oct 26 '05 #14

P: n/a
Dr John Stockton wrote on 26 okt 2005 in comp.lang.javascript:
JRS: In article <Xn********************@194.109.133.242>, dated Tue, 25
Oct 2005 19:48:28, seen in news:comp.lang.javascript, Evertjan.
<ex**************@interxnl.net> posted :
Dr John Stockton wrote on 25 okt 2005 in comp.lang.javascript:
setTimeout("show()", 20e3) // ?


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


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


I knew you would say that!

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 26 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.