Java rotating image script

Discussion in 'Javascript' started by mikeoley@hotmail.com, Oct 24, 2005.

  1. Guest

    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, 2005
    #1
    1. Advertising

  2. Evertjan. Guest

    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)
     
    Evertjan., Oct 24, 2005
    #2
    1. Advertising

  3. Guest

    Would that be the reason? I'm working on getting it turned on, but the
    guy is taking forever for some reason.
     
    , Oct 24, 2005
    #3
  4. Evertjan. Guest

    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)
     
    Evertjan., Oct 24, 2005
    #4
  5. Guest

    >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, 2005
    #5
  6. Guest

    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, 2005
    #6
  7. Evertjan. Guest

    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)
     
    Evertjan., Oct 24, 2005
    #7
  8. Evertjan. Guest

    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)
     
    Evertjan., Oct 24, 2005
    #8
  9. Guest

    Thank you. As you can tell I'm new to this. I appreciate it.
     
    , Oct 24, 2005
    #9
  10. Guest

    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, 2005
    #10
  11. Evertjan. Guest

    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)
     
    Evertjan., Oct 24, 2005
    #11
  12. JRS: In article <Xns96F9CD0079E6Ceejj99@194.109.133.242>, dated Mon, 24
    Oct 2005 18:09:09, seen in news:comp.lang.javascript, Evertjan.
    <> 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>.
     
    Dr John Stockton, Oct 25, 2005
    #12
  13. Evertjan. Guest

    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)
     
    Evertjan., Oct 25, 2005
    #13
  14. JRS: In article <Xns96FADDD7D961Beejj99@194.109.133.242>, dated Tue, 25
    Oct 2005 19:48:28, seen in news:comp.lang.javascript, Evertjan.
    <> 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.
     
    Dr John Stockton, Oct 26, 2005
    #14
  15. Evertjan. Guest

    Dr John Stockton wrote on 26 okt 2005 in comp.lang.javascript:
    > JRS: In article <Xns96FADDD7D961Beejj99@194.109.133.242>, dated Tue, 25
    > Oct 2005 19:48:28, seen in news:comp.lang.javascript, Evertjan.
    > <> 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)
     
    Evertjan., Oct 26, 2005
    #15
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mark | r

    rotating an image

    mark | r, Jul 2, 2003, in forum: HTML
    Replies:
    4
    Views:
    4,728
    Mark Parnell
    Jul 2, 2003
  2. bob
    Replies:
    0
    Views:
    433
  3. bob
    Replies:
    0
    Views:
    622
  4. Michael

    about image rotating

    Michael, Jun 24, 2008, in forum: ASP .Net
    Replies:
    4
    Views:
    354
    Michael
    Jun 24, 2008
  5. AJ
    Replies:
    5
    Views:
    501
    Jonathan Lee
    Dec 15, 2009
Loading...

Share This Page