Thanks pronerd.
I'm so close!
I made the following changes:
-
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 = ""
-
if (ads[adNumber].href) {
-
tempCode += ('<a href="'+ ads[adNumber].href +'" target="_blank" >')
-
}
-
tempCode += ('<img src="' + ads[adNumber].src + '" width="550" height="60" \n' )
-
tempCode += (' onLoad="setTimeout(\'newAd()\', 1000);">')
-
if (ads[adNumber].href) {
-
tempCode += ('</a>')
-
}
-
alert("The value of the variable is "+tempCode);
-
return tempCode;
-
}
-
-
-
function newAd(){
-
current_ad++;
-
if (current_ad > numAds){
-
current_ad = 1;}
-
//if (document.all){
-
write(getCode(current_ad));
-
// }
-
}
-
-
function write(text){
-
if (document.layers) {
-
document.bannerAd.document.write(text)
-
document.bannerAd.document.close();
-
}
-
else
-
if (document.all)
-
document.all.bannerAd.innerHTML = text
-
}
The alert window shows the following:
<a href="link" targer="_blank">
<img scr="image" width="550" height="60"
onLoad="setTimeout('newAd()';1000);'></a>
(I've replaced image and link, of course)
When I load the page, I get the alert window; then shortly after I get another alert window (so it's going through the getCode() function), but it doesn't change the image and I don't get any further alerts.
Any ideas?
Thanks!