alt view for images in an array

Discussion in 'Javascript' started by Rick, Aug 7, 2003.

  1. Rick

    Rick Guest

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

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



    var links = new Array

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



    function loadBanner(){

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

    // 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*3600+mins*60+secs
    if (curTime>=closeTime){
    if (i < 5){
    i++;
    document.banner.src = eval("banner" + i +
    ".src");
    }
    else{
    i = 1;
    document.banner.src = eval("banner" + i +
    ".src");
    } loadBanner();
    }
    else{
    window.setTimeout("Timer()",1000)}

    }

    function clickLink(){
    top.location = links
    }

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

    </script>
    Rick, Aug 7, 2003
    #1
    1. Advertising

  2. Rick

    Jim Ley Guest

    On 7 Aug 2003 13:52:38 -0700, (Rick) wrote:

    > document.banner.src = eval("banner" + i +
    >".src");


    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.javascript FAQ - http://jibbering.com/faq/
    Jim Ley, Aug 8, 2003
    #2
    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. VB Programmer
    Replies:
    1
    Views:
    591
    VB Programmer
    Jul 10, 2003
  2. =?Utf-8?B?UmFlZCBTYXdhbGhh?=

    Icon View and list View in ASP.NET

    =?Utf-8?B?UmFlZCBTYXdhbGhh?=, Mar 7, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    494
    =?Utf-8?B?UmFlZCBTYXdhbGhh?=
    Mar 7, 2005
  3. Luqman
    Replies:
    2
    Views:
    3,811
    Luqman
    Feb 1, 2006
  4. Parthiv Joshi
    Replies:
    1
    Views:
    658
    Samuel L Matzen
    Jul 6, 2004
  5. Rick

    alt tags in images

    Rick, Aug 7, 2003, in forum: Javascript
    Replies:
    2
    Views:
    58
    Richard Cornford
    Aug 9, 2003
Loading...

Share This Page