Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > alt view for images in an array

Reply
Thread Tools

alt view for images in an array

 
 
Rick
Guest
Posts: n/a
 
      08-07-2003
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[i]
}

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

</script>
 
Reply With Quote
 
 
 
 
Jim Ley
Guest
Posts: n/a
 
      08-08-2003
On 7 Aug 2003 13:52:38 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (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/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make a week view and day view calendar just like month view calendar in .NET ? Parthiv Joshi ASP .Net Web Controls 1 07-06-2004 03:15 PM
alt.autos.porsche928,rec.humor.oracle.d,alt.balordi.it,alt.computer,sci.med.laboratory . Computer Information 1 06-18-2004 08:44 AM



Advertisments