Newbie question - only first word of alt tag displays!

C

Chris Curtis

Actually I'm not sure even newbie qualifies! I originally posted this in the
Java help group!!
I'm trying to adapt an ad rotating script I found on the net yesterday.
The author's contact details no longer work.

All I've done is add a variable to create a related alt tag.
However, all that displays is the first word!
I suspect it is something simple.

Remember, I'm a total novice!

Regards
Chris Curtis

The page can be viewed at
http://www.brss.org.uk/indexbannerscrpt.htm

The relevant part of the script:

var refreshTime = 5000;
var numAds = 3;

function makeAd() {
this.width = ''
this.height = ''
this.src = ''
this.href = ''
this.alt = ''
this.mouseover = ''
}

var ads = new Array()
for(var i = 1; i <= numAds; i++) { ads = new makeAd() }
i = 1;

ads.width = "200"
ads.height = "130"
ads.src = "images/blackcatcomputers.jpg"
ads.href = "http://www.blackcatcomputers.co.uk"
ads.alt = "Black Cat Computers Tel 01527 889584"
ads.mouseover = "Black Cat Computers Tel 01527 889584"
i++

DETAILS OF OTHER TWO ADS GO HERE

var myCode = '';
do {
var n= Math.floor(Math.random() * (numAds + 1) + 1);
} while(n > numAds);
var current_ad = n;
myCode = getCode(n);

function getCode(adNumber){
var tempCode = ""
tempCode += ('<a href="'+ ads[adNumber].href + ' "target=_blank"' +
ads[adNumber].width +'" \n')
tempCode += ('onMouseOver="status=\''+ ads[adNumber].mouseover +'\';return
true" \n')
tempCode += ('onMouseOut="status=\'\'"> \n')
tempCode += ('<img src="' + ads[adNumber].src + '" alt=' +
ads[adNumber].alt + '" width=' + adsadNumber].width)
tempCode += (' onLoad="setTimeout(\'newAd();\',' + refreshTime + ');"')
tempCode += ('\n height=' + ads[adNumber].height + ' border=0 >')
tempCode += ('</a>')
return tempCode;
}
 
R

Richard Cornford

Chris Curtis wrote:
tempCode += ('<img src="' + ads[adNumber].src + '" alt=' +
^
There is no opening double quote in your string literal.
ads[adNumber].alt + '" width=' + adsadNumber].width)
<snip> ^^
- but there is a closing double quote. That is the sort of thing that
will throw a browser off. As unquoted attribute values may not contain
spaces without the quote the first space defines the end of the ALT
_attribute_ value, and so you only see the first word.

Richard.
 
C

Chris Curtis

Richard Cornford said:
Chris Curtis wrote:
tempCode += ('<img src="' + ads[adNumber].src + '" alt=' +
^
There is no opening double quote in your string literal.
ads[adNumber].alt + '" width=' + adsadNumber].width)
<snip> ^^
- but there is a closing double quote. That is the sort of thing that
will throw a browser off. As unquoted attribute values may not contain
spaces without the quote the first space defines the end of the ALT
_attribute_ value, and so you only see the first word.

Richard.

Many thanks Richard!

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top