Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Newbie question - only first word of alt tag displays!

Reply
Thread Tools

Newbie question - only first word of alt tag displays!

 
 
Chris Curtis
Guest
Posts: n/a
 
      05-17-2006
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[i] = new makeAd() }
i = 1;

ads[i].width = "200"
ads[i].height = "130"
ads[i].src = "images/blackcatcomputers.jpg"
ads[i].href = "http://www.blackcatcomputers.co.uk"
ads[i].alt = "Black Cat Computers Tel 01527 889584"
ads[i].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;
}


 
Reply With Quote
 
 
 
 
Richard Cornford
Guest
Posts: n/a
 
      05-17-2006
Chris Curtis wrote:
<snip>
> 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.

 
Reply With Quote
 
 
 
 
Chris Curtis
Guest
Posts: n/a
 
      05-17-2006
"Richard Cornford" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Chris Curtis wrote:
> <snip>
>> 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


 
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 do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
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