Rotating Images Javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mikeoley@hotmail.com

    Rotating Images Javascript

    Ok what I'm trying to do should be fairly simple.

    I have an image on a page that rotates with 4 other images.

    All I want to do is be able to link this images to different parts of
    the site when the user clicks on them. I can't figure out how to add
    the "HREF" tag in there to make it work though. It's the bottom left
    image that rotates. Thanks for any help or advice

    <a href="http://www.eg-designdev.com/aircylinders/index3.jsp">Air
    Cylinders</a>

  • mikeoley@hotmail.com

    #2
    Re: Rotating Images Javascript

    upon thinking about it, I thought i'd just post the code.


    <script>
    <!--
    var pic, alt, caption;

    //add as many lines as there are pictures - remove unused
    //for each picture added here there must be an entry for the alt
    tag and caption below
    pic = new Array;
    pic[0] = "images/flash-ph6.jpg"; <----HOW DO I LINK THESE?
    pic[1] = "images/flash-ph8.jpg";
    pic[2] = "images/flash-ph7.jpg";
    pic[3] = "images/flash-ph6.jpg";



    //additions here will be used as the alternate tag for the web
    browser and speech readers
    alt = new Array;
    alt[0] = "";
    alt[1] = "";
    alt[2] = "";
    alt[3] = "";



    //additions here will appear under the picture on the page
    cap = new Array;
    cap[0] = "";
    cap[1] = "";
    cap[2] = "";
    cap[3] = "";


    var now = new Date();
    var seed = now.getTime() % 0xffffffff;

    function rand(n) {
    seed = (0x015a4e35 * seed) % 0x7fffffff;
    return ( seed >> 16 ) % n;
    }

    var num2 = rand(4);

    document.write( "<img alt='" + alt[num2] + "' name='main_imag e'
    src='" + pic[num2] + "' width='151' height='101' border='0' >");
    // use the next line if we want image to link to full size version
    //document.write( "<a href='" + pic[num2] + "'><img alt='" + alt[num2] +
    "' name='main_imag e' src='" + pic[num2] + "' width='151' height='101'
    border='0' ></a>");
    document.write( "<h3>" + cap[num2]);

    //-->
    </script>

    Comment

    • Dominic Myers

      #3
      Re: Rotating Images Javascript

      <mikeoley@hotma il.com> wrote in message
      news:1129903109 .272811.79200@z 14g2000cwz.goog legroups.com...[color=blue]
      > upon thinking about it, I thought i'd just post
      > the code.
      >
      >
      > <script>
      > <!--
      > var pic, alt, caption;
      >
      > //add as many lines as there are pictures -
      > remove unused
      > //for each picture added here there must be
      > an entry for the alt
      > tag and caption below
      > pic = new Array;
      > pic[0] = "images/flash-ph6.jpg";
      > <----HOW DO I LINK THESE?
      > pic[1] = "images/flash-ph8.jpg";
      > pic[2] = "images/flash-ph7.jpg";
      > pic[3] = "images/flash-ph6.jpg";
      >
      >
      >
      > //additions here will be used as the
      > alternate tag for the web
      > browser and speech readers
      > alt = new Array;
      > alt[0] = "";
      > alt[1] = "";
      > alt[2] = "";
      > alt[3] = "";
      >
      >
      >
      > //additions here will appear under the picture
      > on the page
      > cap = new Array;
      > cap[0] = "";
      > cap[1] = "";
      > cap[2] = "";
      > cap[3] = "";
      >
      >
      > var now = new Date();
      > var seed = now.getTime() % 0xffffffff;
      >
      > function rand(n) {
      > seed = (0x015a4e35 * seed) % 0x7fffffff;
      > return ( seed >> 16 ) % n;
      > }
      >
      > var num2 = rand(4);
      >
      > document.write( "<img alt='" + alt[num2] + "'
      > name='main_imag e'
      > src='" + pic[num2] + "' width='151' height='101'
      > border='0' >");
      > // use the next line if we want image to link to
      > full size version
      > //document.write( "<a href='" + pic[num2] +
      > "'><img alt='" + alt[num2] +
      > "' name='main_imag e' src='" + pic[num2] + "'
      > width='151' height='101'
      > border='0' ></a>");
      > document.write( "<h3>" + cap[num2]);
      >
      > //-->
      >
      > </script>
      >[/color]

      I've got something similar to what it is you're
      trying to do here: http://indigo.camshag.co.uk. Do
      me a favour though and tell me if the banner image
      is visible on your browser setup please?
      Dom


      Comment

      Working...