alt view for images in an array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rick

    alt view for images in an array

    How would you create a different alt view for each image in the following?

    <script language="JavaS cript">
    var i = 1;
    banner1= new Image();
    banner1.src = "image1jpg" ;
    banner2= new Image();
    banner2.src = "image2.jpg ";



    var links = new Array

    links[1] = "http://www.centerforpl antconservation .org/testing/image1.jpg"
    links[2] = "http://www.centerforpl antconservation .org/testing/image2.jpg"



    function loadBanner(){

    var time= new Date();
    hours= time.getHours() ;
    mins= time.getMinutes ();
    secs= time.getSeconds ();
    closeTime=hours *3600+mins*60+s ecs;

    // Change this number to increase decrease the rotation speed
    closeTime+=3;

    Timer();

    }

    function Timer(){
    var time= new Date();
    hours= time.getHours() ;
    mins= time.getMinutes ();
    secs= time.getSeconds ();
    curTime=hours*3 600+mins*60+sec s
    if (curTime>=close Time){
    if (i < 5){
    i++;
    document.banner .src = eval("banner" + i +
    ".src");
    }
    else{
    i = 1;
    document.banner .src = eval("banner" + i +
    ".src");
    } loadBanner();
    }
    else{
    window.setTimeo ut("Timer()",10 00)}

    }

    function clickLink(){
    top.location = links[i]
    }

    function changeAlt(){
    var image = ??????
    ??????
    }

    </script>
  • Jim Ley

    #2
    Re: alt view for images in an array

    On 7 Aug 2003 13:52:38 -0700, luhsig@globalcc s.net (Rick) wrote:
    [color=blue]
    > document.banner .src = eval("banner" + i +
    >".src");[/color]

    don't use eval, don't just use document.

    so:

    document.images['banner'].src=window['banner'+i].src
    document.images['banner'].alt=window['banner'+i].alt

    for alt and src.

    Jim.
    --
    comp.lang.javas cript FAQ - http://jibbering.com/faq/

    Comment

    Working...