faqts : Computers : Programming : Languages : JavaScript : Language Core

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 2 people (50%) answered Yes
Recently 1 of 2 people (50%) answered Yes

Entry

Why is the script on http://www.nedcom.nl/mubanieuw/rotator.htm messing up the ALTs?

Jun 12th, 2001 12:34
Bart Hoeksel, Bart Hoeksel / Jean Bernard Valentaten


The answer to this question (after much brainstorming) has been solved 
by Jean Bernard Valentaten:
The function 
function getNextAd (img, linkIndex) {
  cur = ++cur % links.length;
  window.img = img;
  window.linkIndex = linkIndex;
  tid = setTimeout(
   'document.links[linkIndex].href = links[cur]; ' +
   'img.src = images[cur]; img.alt = alts[cur];', delay);
}
had to be written as
function getNextAd (img, linkIndex) {
  cur = ++cur % links.length;
  window.img = img;
  window.linkIndex = linkIndex;
  tid = setTimeout('document.links[linkIndex].href = links[cur];
  img.alt = alts[cur]; img.src = images[cur];', delay);
}
so the alt is assigned before the src is (the error doesn't occure 
then).
Only NN is still messing up now, but that was to be expected...
Thanks, Jean Bernard,
Bart