![]() Topic awaiting preservation: multiple ad image arrays on one page (Page 1 of 1) |
|
|---|---|
|
Nervous Wreck (II) Inmate From: North Carolina |
posted 01-29-2006 23:37
Hey all just found this site and was hoping someone could answer what I'd think would be an easy task. I have one rotating script on my page for rotating pictures but I want to have two more running. I have my JavaScript in another folder for SEO reasons and want to keep it that way. I thought if I just named the scripts different I.e. " imagearray.js" is the first rotate script and "imagearray2.js" is the second . |
|
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 01-30-2006 08:47
depends on the script... you might have to change the script to actually use the other adbanner place. |
|
Bipolar (III) Inmate From: Sweden |
posted 01-30-2006 12:58
All global variables in imagearray.js will be replaced by imagearray2.js if it is included last. |
|
Nervous Wreck (II) Inmate From: North Carolina |
posted 01-30-2006 14:44
Hey TwoD could you put that in English please? code: <!--
adImages = new Array("photos/118964asm.jpg" ,"photos/118964bsm.jpg" ,"photos/118964csm.jpg" , "photos/118964dsm.jpg", "photos/118964esm.jpg" , "photos/118964fsm.jpg" , "photos/118964gsm.jpg" )
thisAd = 0
imgCt = adImages.length
function rotate() {
if (document.images) {
thisAd++
if (thisAd == imgCt) {
thisAd = 0
}
document.adBanner.src=
adImages[thisAd]
setTimeout("rotate()", 3 * 1000)
}
}
//-->
code: <!--
adImages = new Array("photos/111014asm.jpg" ,"photos/111014bsm.jpg" ,"photos/111014csm.jpg" , "photos/111014dsm.jpg" )
thisAd = 0
imgCt = adImages.length
function rotate() {
if (document.images) {
thisAd++
if (thisAd == imgCt) {
thisAd = 0
}
document.adBanner2.src=
adImages[thisAd]
setTimeout("rotate()", 3 * 1000)
}
}
//-->
code: <script language="JavaScript" Src="scripts/imagearray.js" TYPE="text/javascript"></script>
code: <script language="JavaScript" Src="scripts/imagearray2.js" TYPE="text/javascript"></script>
code: <img src="photos/118964asm.jpg" alt="creek front cabin" width="150" height="97" border="4" Name="adBanner"></a>
code: <img src="photos/111014asm.jpg" alt="floatplane hanger " width="150" height="94" border="4" Name="adBanner2" >
|
|
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 01-30-2006 15:20
you need to rename the functions something like rotate and rotate2 and also change the call in the timeout. |
|
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 01-30-2006 16:27
plus seperate the thisAds and the imgCts and the adImages... all those need a 2 at then end... but honestly this is patchwork, code: var addRotators = new Array();
function addRotator_Rotate()
{
if (document.images)
{
this.thisAd++;
if (this.thisAd == this.imgCt)
{
thisAd = 0;
}
//alert('showing' + this.adImages[this.thisAd]);
var els = document.getElementsByName(this.elementName)[0];
if (els && els[0])
els[0].src= this.adImages[this.thisAd];
}
}
function addAdRotator(adImages,elementName)
{
this.adImages = adImages;
this.elementName = elementName;
this.thisAd = 0;
this.imgCt = adImages.length ;
this.rotate = addRotator_Rotate;
addRotators.push(this);
}
function rotateAll()
{
for (x in addRotators)
{
addRotators[x].rotate();
}
window.setTimeout('rotateAll()',3000);
}
addAdRotator(
new Array("photos/111014asm.jpg" ,"photos/111014bsm.jpg" ,"photos/111014csm.jpg" , "photos/111014dsm.jpg" ),
'adbanner');
rotateAll();
|
|
Nervous Wreck (II) Inmate From: North Carolina |
posted 01-30-2006 19:20
Okay wow! I tried to set up the code above but I'm not doing something right. prefer to "KISS" it. code: <!--
adImages2 = new Array("photos/111014asm.jpg" ,"photos/111014bsm.jpg" ,"photos/111014csm.jpg" , "photos/111014dsm.jpg" )
thisAd2 = 0
imgCt2 = adImages2.length
function rotate2() {
if (document.images) {
thisAd2++
if (thisAd2 == imgCt) {
thisAd2 = 0
}
document.adBanner2.src=
adImages2[thisAd2]
setTimeout("rotate2()", 3 * 1000)
}
}
//-->
code: <body onLoad="rotate()" , "rotate2()">
|
|
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 01-30-2006 21:38
code: <body onLoad="rotate();rotate2()">
|
|
Bipolar (III) Inmate From: North Carolina |
posted 01-31-2006 01:12
Great got that ... thanks but something's still not jiving in the code posted above I must be missing a "2" somewhere. Hate to be a pest but anybody see the problem? |
|
Paranoid (IV) Inmate From: Norway |
posted 01-31-2006 01:41
Sorry to be a pest in my turn, but to me the problem is that somebody forgot to read the fucking manual : |
|
Bipolar (III) Inmate From: North Carolina |
posted 01-31-2006 02:11
whoa! I was just trying to figure out what was wrong with my code. Didn't know I came across such an UNFRIENDLY place. Thanks to those that helped but obviously I'm not welcome here.! Don't worry I won't come back.... |
|
Paranoid (IV) Inmate From: Norway |
posted 01-31-2006 09:56
sward: You are welcome. |
|
Bipolar (III) Inmate From: Sweden |
posted 02-03-2006 01:43
Whoa! This thread grew faster than I thought it would... |