I found this piece of javascript code on the net which scrolls through images, i have tried to add top & left co-ordinates to it so I could move the position of the images however it does not seem to work could someone have a quick look to see what I am doing wrong Please
This is the original code
and this is my amended code with the added lines in Blue
Regards
Olly
This is the original code
Code:
//-3) time between switching the ad, in milliseconds -\\
var refreshTime = 5000; //- 5000 ms = 5 seconds -\\
//-4) number of ads to rotate -\\
var numAds = 3;
function makeAd() {
this.width = ''
this.height = ''
this.src = ''
this.href = ''
this.mouseover = ''
this.sponsor = ''
}
var ads = new Array()
for(var i = 1; i <= numAds; i++) { ads[i] = new makeAd() }
//- 5) Copy and paste the lines between the banner definition for
//each banner you want to rotate and be sure to change numAds to
//the number of banners (look about 15 lines up for numAds)
i = 1;
/*------------begin banner definition----------*/
ads[i].width = "200" //width of image
ads[i].height = "152" //height of image
ads[i].src = "Images/MelJoe.jpg" //image url
ads[i].href = "" //link url
ads[i].mouseover = "" //text to display when mouse moves over banner
ads[i].sponsor = "" //text to display for text link under banner
i++
/*-------------end banner definition-----------*/
ads[i].width = "200" //width of image
ads[i].height = "152" //height of image
ads[i].src = "Images/sharon.jpg"
ads[i].href = ""
ads[i].mouseover = ""
ads[i].sponsor = ""
i++
ads[i].width = "200" //width of image
ads[i].height = "152" //height of image
ads[i].src = "Images/Grandchildren.jpg"
ads[i].href = ""
ads[i].mouseover = ""
ads[i].sponsor = ""
i++
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 +'" \n')
tempCode += ('onMouseOver="status=\''+ ads[adNumber].mouseover +'\';return true" \n')
tempCode += ('onMouseOut="status=\'\'"> \n')
tempCode += ('<img src="' + ads[adNumber].src + '" width=' + ads[adNumber].width)
tempCode += (' onLoad="setTimeout(\'newAd();\',' + refreshTime + ');"')
tempCode += ('\n height=' + ads[adNumber].height + ' border=0 >')
tempCode += ('</a>')
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.bannerAd1.document.write(text)
document.bannerAd1.document.close();
}
else
if (document.all)
document.all.bannerAd1.innerHTML = text
}
and this is my amended code with the added lines in Blue
Code:
//-3) time between switching the ad, in milliseconds -\\
var refreshTime = 5000; //- 5000 ms = 5 seconds -\\
//-4) number of ads to rotate -\\
var numAds = 3;
function makeAd() {
this.width = ''
this.height = ''
this.src = ''
this.href = ''
this.mouseover = ''
this.sponsor = ''
[COLOR=blue][b]this.top = ''
this.left = ''[/b][/color]
}
var ads = new Array()
for(var i = 1; i <= numAds; i++) { ads[i] = new makeAd() }
//- 5) Copy and paste the lines between the banner definition for
//each banner you want to rotate and be sure to change numAds to
//the number of banners (look about 15 lines up for numAds)
i = 1;
/*------------begin banner definition----------*/
ads[i].width = "200" //width of image
ads[i].height = "152" //height of image
ads[i].src = "Images/MelJoe.jpg" //image url
ads[i].href = "" //link url
ads[i].mouseover = "" //text to display when mouse moves over banner
ads[i].sponsor = "" //text to display for text link under banner
[COLOR=blue][b]ads[i].top = "200" // set top of image
ads[i].left = "200" // set left for image[/b][/color]
i++
/*-------------end banner definition-----------*/
ads[i].width = "200" //width of image
ads[i].height = "152" //height of image
ads[i].src = "Images/sharon.jpg"
ads[i].href = ""
ads[i].mouseover = ""
ads[i].sponsor = ""
[COLOR=blue][b]ads[i].top = "200" // set top of image
ads[i].left = "200" // set left for image[/b][/color]
i++
ads[i].width = "200" //width of image
ads[i].height = "152" //height of image
ads[i].src = "Images/Grandchildren.jpg"
ads[i].href = ""
ads[i].mouseover = ""
ads[i].sponsor = ""
[COLOR=blue][b]ads[i].top = "200" // set top of image
ads[i].left = "200" // set left for image[/b][/color]
i++
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 +'" \n')
tempCode += ('onMouseOver="status=\''+ ads[adNumber].mouseover +'\';return true" \n')
tempCode += ('onMouseOut="status=\'\'"> \n')
tempCode += ('<img src="' + ads[adNumber].src + '" width=' + ads[adNumber].width)
tempCode += (' onLoad="setTimeout(\'newAd();\',' + refreshTime + ');"')
tempCode += ('\n height=' + ads[adNumber].height + ' border=0 >')
tempCode += ('</a>')
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.bannerAd1.document.write(text)
document.bannerAd1.document.close();
}
else
if (document.all)
document.all.bannerAd1.innerHTML = text
}
Regards
Olly