TinyPortal

Development => Block Codes => Topic started by: rebelrose on August 23, 2006, 09:45:22 PM

Title: Rotating Banners
Post by: rebelrose on August 23, 2006, 09:45:22 PM
Rotating Banners refreshes without you having to refresh a page. You can see it here.

http://www.rebelrosenetworks.com/forum/index.php



<center>

<ilayer id="l1">
<layer id="l2">
<div id="l1">
<div id="l3" style="position:relative">
</div>
</div>
</layer>
</ilayer>





<script language="JavaScript">
<!--


var bannerArray = new Array();
var myCount=0;
// Banner Code Assignment
bannerArray[0] = "<A HREF=\"http://www.yourdomain.com\"><IMG SRC=\"http://www.yourdomain.com/banner.jpg\" border=\"0\" width=\"470\" height=\"60\"></A>";
bannerArray[1] = "<A HREF=\"http://www.yourdomain.net\"><IMG SRC=\"http://www.yourdomain.com/banner.jpg\" border=\"0\" width=\"470\" height=\"60\"></A>";
bannerArray[2] = "<A HREF=\"http://www.yourdomain.net\"><IMG SRC=\"http://www.yourdomain.com/banner.jpg\" border=\"0\" width=\"470\" height=\"60\"></A>";
bannerArray[3] = "<A HREF=\"http://www.yourdomain.net\"><IMG SRC=\"http://www.yourdomain.com/banner.jpg\" border=\"0\" width=\"470\" height=\"60\"></A>";
bannerArray[4] = "<A HREF=\"http://www.yourdomain.net\"><IMG SRC=\"http://www.yourdomain.com/banner.jpg\" border=\"0\" width=\"470\" height=\"60\"></A>";

bannerRotate();

function bannerRotate() {

if(myCount > bannerArray.length-1){myCount=0;}

// Write out rotation
if (document.all){ // it is IE
document.all.l3.innerHTML=bannerArray[myCount];
}

else if (document.layers){ // it is NN

document.layers.l1.document.layers.l2.document.open();
document.layers.l1.document.layers.l2.document.write(bannerArray[myCount]);
document.layers.l1.document.layers.l2.document.close();
}
setTimeout("bannerRotate()", 3000);
myCount++;
}
// -->
</script>

</center>



--edit by IchBin
Updated code for it to work in other browsers.
http://www.tinyportal.net/index.php/topic,7747.msg209101.html#msg209101
Title: Re: Rotating Banners
Post by: rebelrose on August 24, 2006, 04:53:17 AM
finally got it working right.
Title: Re: Rotating Banners
Post by: eli on November 03, 2006, 04:44:59 AM
Parse error: syntax error, unexpected '<' in /home/username/public_html/Sources/Load.php(1708) : eval()'d code(35) : eval()'d code on line 1
Title: Re: Rotating Banners
Post by: JPDeni on November 03, 2006, 05:20:49 AM
Put it in a scriptbox, not a phpbox.
Title: Re: Rotating Banners
Post by: eli on November 03, 2006, 12:36:57 PM
Doesn't display the image. Shows up on the source code as this:
Quote<script language="JavaScript">
<!--


var bannerArray = new Array();
var myCount=0;
// Banner Code Assignment
bannerArray[0] = "<A HREF=\"http://www.devira.info\"><IMG SRC=\"http://www.devira.info/images/brooke/jennaboyd3a.jpg\" border=\"0\" width=\"133\" height=\"200\"></A>";
bannerArray[1] = "<A HREF=\"http://www.devira.info\"><IMG SRC=\"http://www.devira.info/images/brooke/jennaboyd5a.jpg\" border=\"0\" width=\"133\" height=\"200\"></A>";
bannerArray[2] = "<A HREF=\"http://www.devira.info\"><IMG SRC=\"http://www.devira.info/images/brooke/jennaboyd6a.jpg\" border=\"0\" width=\"133\" height=\"200\"></A>";
bannerArray[3] = "<A HREF=\"http://www.devira.info\"><IMG SRC=\"http://www.devira.info/images/brooke/jennaboyd7a.jpg\" border=\"0\" width=\"133\" height=\"200\"></A>";
bannerArray[4] = "<A HREF=\"http://www.devira.info\"><IMG SRC=\"http://www.devira.info/images/brooke/jennaboyd3a.jpg\" border=\"0\" width=\"133\" height=\"200\"></A>";

bannerRotate();

function bannerRotate() {

if(myCount > bannerArray.length-1){myCount=0;}

// Write out rotation
   if (document.all){         // it is IE
      document.all.l3.innerHTML=bannerArray[myCount];
   }

   else if (document.layers){   // it is NN

   document.layers.l1.document.layers.l2.document.open();
   document.layers.l1.document.layers.l2.document.write(bannerArray[myCount]);
   document.layers.l1.document.layers.l2.document.close();
   }
setTimeout("bannerRotate()", 3000);
myCount++;
}
// -->
</script>

But no execution.
Title: Re: Rotating Banners
Post by: pvcblue on November 03, 2006, 01:11:23 PM
Eliana I use the code Rose shows and it works fine I just removed the size restraints and put it in a table - make sure you put it in a script box -

<center>
<table width="470" height="85" border="0" align="center" cellpadding="2" cellspacing="0">
Ã,  <tr>
Ã,  Ã,  <td height="100" align="center" valign="middle"><center>
Ã,  Ã,  Ã,  Ã,  <ilayer id="l1">
Ã,  Ã,  Ã,  Ã,  <layer id="l2">
Ã,  Ã,  Ã,  Ã,  <div id="l1">
Ã,  Ã,  Ã,  Ã,  Ã,  <div id="l3" style="position:relative"> </div>
Ã,  Ã,  Ã,  Ã,  </div>
Ã,  Ã,  Ã,  Ã,  </layer>
Ã,  Ã,  Ã,  Ã,  </ilayer>
Ã,  Ã,  Ã,  Ã,  <script language="JavaScript">
<!--


var bannerArray = new Array();
var myCount=0;
// Banner Code Assignment
bannerArray[0] = "<A HREF=\"http://LINKED WEBSITE URL HERE\" target=\"_blank\"><IMG SRC=\"IMAGE SOURCE HERE\" border=\"0\"></A>";
bannerArray[1] = "<A HREF=\"http://LINKED WEBSITE URL HERE\" target=\"_blank\"><IMG SRC=\"IMAGE SOURCE HERE\" border=\"0\"></A>";
bannerArray[2] = "<A HREF=\"http://LINKED WEBSITE URL HERE\" target=\"_blank\"><IMG SRC=\"IMAGE SOURCE HERE\" border=\"0\"></A>";
bannerArray[3] = "<A HREF=\"http://LINKED WEBSITE URL HERE\" target=\"_blank\"><IMG SRC=\"IMAGE SOURCE HERE\" border=\"0\"></A>";
bannerArray[4] = "<A HREF=\"http://LINKED WEBSITE URL HERE\" target=\"_blank\"><IMG SRC=\"IMAGE SOURCE HERE\" border=\"0\"></A>";
bannerArray[5] = "<A HREF=\"http://LINKED WEBSITE URL HERE\" target=\"_blank\"><IMG SRC=\"IMAGE SOURCE HERE\" border=\"0\"></A>";
bannerArray[6] = "<A HREF=\"http://LINKED WEBSITE URL HERE\" target=\"_blank\"><IMG SRC=\"IMAGE SOURCE HERE\" border=\"0\"></A>";
bannerArray[7] = "<A HREF=\"http://LINKED WEBSITE URL HERE\" target=\"_blank\"><IMG SRC=\"IMAGE SOURCE HERE\" border=\"0\"></A>";

bannerRotate();

function bannerRotate() {

if(myCount > bannerArray.length-1){myCount=0;}

// Write out rotation
if (document.all){ // it is IE
document.all.l3.innerHTML=bannerArray[myCount];
}

else if (document.layers){ // it is NN

document.layers.l1.document.layers.l2.document.open();
document.layers.l1.document.layers.l2.document.write(bannerArray[myCount]);
document.layers.l1.document.layers.l2.document.close();
}
setTimeout("bannerRotate()", 3000);
myCount++;
}
// -->
</script>
Ã,  Ã,  Ã,  </center></td>
Ã,  </tr>
</table>
</center>
Title: Re: Rotating Banners
Post by: akulion on November 03, 2006, 02:04:15 PM
Eliana Tamerin turn the EDITOR off from your settngs area and it wont do that :up:
Title: Re: Rotating Banners
Post by: eli on November 03, 2006, 09:06:49 PM
It still does not work, even if I turn off the editor. I added a new block without the editor and that doesn't work. The images show up fine when you go to the URL separately. It is in a script box, no editor, with the URLs working. What is the problem, then? The code? What TP version is this made for?
Title: Re: Rotating Banners
Post by: rebelrose on November 03, 2006, 09:15:46 PM
It is a script for no special version of TP,  can you post the code as you are using so we can take a look at it and maybe a link to your site?
Title: Re: Rotating Banners
Post by: rebelrose on November 03, 2006, 09:32:56 PM
ok, first problem is you changed the script and added bbc code, you have [/url] at the end of each one.

I have it up on my test site with your code and it is working great:

http://rebelrose.com/newtheme/smf/index.php

Try this:


<center>
<table width="470" height="85" border="0" align="center" cellpadding="2" cellspacing="0">
  <tr>
    <td height="100" align="center" valign="middle"><center>
        <ilayer id="l1">
        <layer id="l2">
        <div id="l1">
          <div id="l3" style="position:relative"> </div>
        </div>
        </layer>
        </ilayer>
<script language="JavaScript">
<!--


var bannerArray = new Array();
var myCount=0;
// Banner Code Assignment
bannerArray[0] = "<A HREF=\"http://www.devira.info\"><IMG SRC=\"http://www.devira.info/images/brooke/jennaboyd3a.jpg\" border=\"0\" width=\"133\" height=\"200\"></a>";
bannerArray[1] = "<A HREF=\"http://www.devira.info\"><IMG SRC=\"http://www.devira.info/images/brooke/jennaboyd5a.jpg\" border=\"0\" width=\"133\" height=\"200\"></a>";
bannerArray[2] = "<A HREF=\"http://www.devira.info\"><IMG SRC=\"http://www.devira.info/images/brooke/jennaboyd6a.jpg\" border=\"0\" width=\"133\" height=\"200\"></a>";
bannerArray[3] = "<A HREF=\"http://www.devira.info\"><IMG SRC=\"http://www.devira.info/images/brooke/jennaboyd7a.jpg\" border=\"0\" width=\"133\" height=\"200\"></a>";
bannerArray[4] = "<A HREF=\"http://www.devira.info\"><IMG SRC=\"http://www.devira.info/images/brooke/jennaboyd3a.jpg\" border=\"0\" width=\"133\" height=\"200\"></a>";

bannerRotate();

function bannerRotate() {

if(myCount > bannerArray.length-1){myCount=0;}

// Write out rotation
   if (document.all){         // it is IE
      document.all.l3.innerHTML=bannerArray[myCount];
   }

   else if (document.layers){   // it is NN

   document.layers.l1.document.layers.l2.document.open();
   document.layers.l1.document.layers.l2.document.write(bannerArray[myCount]);
   document.layers.l1.document.layers.l2.document.close();
   }
setTimeout("bannerRotate()", 3000);
myCount++;
}
// -->
</script>
</center></td>
  </tr>
</table>
</center>
Title: Re: Rotating Banners
Post by: eli on November 03, 2006, 09:35:15 PM
Quote<center>

<ilayer id="l1">
<layer id="l2">
<div id="l1">
<div id="l3" style="position:relative">
</div>
</div>
</layer>
</ilayer>





<script language="JavaScript">
<!--


var bannerArray = new Array();
var myCount=0;
// Banner Code Assignment
bannerArray[0] = "<A HREF=\"http://www.devira.info\"><IMG SRC=\"http://www.devira.info/images/brooke/jennaboyd3a.jpg\" border=\"0\" width=\"133\" height=\"200\"></A>";
bannerArray[1] = "<A HREF=\"http://www.devira.info\"><IMG SRC=\"http://www.devira.info/images/brooke/jennaboyd5a.jpg\" border=\"0\" width=\"133\" height=\"200\"></A>";
bannerArray[2] = "<A HREF=\"http://www.devira.info\"><IMG SRC=\"http://www.devira.info/images/brooke/jennaboyd6a.jpg\" border=\"0\" width=\"133\" height=\"200\"></A>";
bannerArray[3] = "<A HREF=\"http://www.devira.info\"><IMG SRC=\"http://www.devira.info/images/brooke/jennaboyd7a.jpg\" border=\"0\" width=\"133\" height=\"200\"></A>";
bannerArray[4] = "<A HREF=\"http://www.devira.info\"><IMG SRC=\"http://www.devira.info/images/brooke/jennaboyd3a.jpg\" border=\"0\" width=\"133\" height=\"200\"></A>";

bannerRotate();

function bannerRotate() {

if(myCount > bannerArray.length-1){myCount=0;}

// Write out rotation
if (document.all){ // it is IE
document.all.l3.innerHTML=bannerArray[myCount];
}

else if (document.layers){ // it is NN

document.layers.l1.document.layers.l2.document.open();
document.layers.l1.document.layers.l2.document.write(bannerArray[myCount]);
document.layers.l1.document.layers.l2.document.close();
}
setTimeout("bannerRotate()", 3000);
myCount++;
}
// -->
</script>

</center>


That's exactly what I put in the scriptbox with no editor.

http://www.kalinini.devira.info is the site. Log in with the username "test" (without the quotes) and the password "test" (without the quotes) to see the block. This is for viewing purposes only, please.

EDIT: FYI, the SMF board changes the entered </a> to [/url]. That's why it shows up as such on the last code I posted, and why it showed up on this one until I put the nobbc tags in.
Title: Re: Rotating Banners
Post by: rebelrose on November 03, 2006, 09:37:36 PM
I see it rotating pictures however I made a mistake in the code, look at the very first image, I forgot to change the [/url]
Title: Re: Rotating Banners
Post by: rebelrose on November 03, 2006, 09:39:12 PM
It never changed the script on any of the ones I used.

Title: Re: Rotating Banners
Post by: eli on November 03, 2006, 09:43:47 PM
Well, it's up with your code, and it still doesn't show. Doesn't work on any skin (thought that might be a source of the problem).

And it changes the script when you post it in SMF. Or at least it did when I posted it. I don't know why. Maybe it's my user settings. Anyways, the point is, I used the exact same code you have, and it doesn't work. I'm about to just give up on it here, because it's getting to be not worth my time. None of the code works, none of the settings work, etc.
Title: Re: Rotating Banners
Post by: rebelrose on November 03, 2006, 09:48:27 PM
I saw it on your site when I logged in the rotating images of a little girl, I don't understand what you are saying it wrong it is even working on my test site. I entered that exact code in a scriptbox.
Title: Re: Rotating Banners
Post by: eli on November 03, 2006, 10:05:27 PM
Well, it doesn't want to work on my browser then. Doesn't make any sense to me, though. Did you make it Firefox 2 unfriendly?
Title: Re: Rotating Banners
Post by: eli on November 03, 2006, 10:13:08 PM
Tested it on Flock (firefox based) as well, doesn't work there. Works on Opera. I can assume it works on IE then. Didn't you make the code compatible with Firefox?
Title: Re: Rotating Banners
Post by: rebelrose on November 03, 2006, 10:25:30 PM
It is just a script code I have had for a while I did not write it. I use IE and yes well it works on that. Did you see it on my test site using your firefox? No one has ever said it didn't work on FF before so I am not sure what to tell you there.
Title: Re: Rotating Banners
Post by: eli on November 03, 2006, 11:01:04 PM
Download Firefox and check it out.
Title: Re: Rotating Banners
Post by: rebelrose on November 03, 2006, 11:02:01 PM
I did just that and I see it does not show in FireFox, I am not sure how to fix that problem, sorry.
Title: Re: Rotating Banners
Post by: pvcblue on November 04, 2006, 04:18:45 AM
Firefox is crap Eliana (jmho) use a real browser - there are so many thing Firefox wont do, see, or recognize it is worthless. The code is a universal code written by a javascript person on a javascript webdev site, attacking Rose for a code isnt right!!!

Title: Re: Rotating Banners
Post by: eli on November 04, 2006, 05:20:36 PM
I did not see anywhere that she had just found the code and tweaked it. I assumed, thus, that she had written it. Don't go flaming me for not knowing that she didn't write it. My apologies to her if I offended her, it was unintentional.
Title: Re: Rotating Banners
Post by: akulion on November 04, 2006, 05:25:29 PM
dont feel bad guys it happens to the best of us :up:

so lets all chill out and have some fun :D
Title: Re: Rotating Banners
Post by: marzi on November 10, 2006, 09:52:28 PM
If it can help:
Using Firefox 2 with Windows 2000 professional ===> does not display any rotating banners.

marzi
Title: Re: Rotating Banners
Post by: G6Cad on November 11, 2006, 09:27:15 AM
You have to have javascript enabled in your browser, it works just fine for me
Title: Re: Rotating Banners
Post by: Techdomain on November 11, 2006, 11:58:17 AM
I tried with FF2 (tried to enable everything I could) and it didnt work. I do agree though - FF is an inferior browser. Just because it is trendy atm...
And no, I am not an IE man (I use linux)
Title: Re: Rotating Banners
Post by: Ghostwriter on February 26, 2007, 06:12:46 PM
I was just wondering how to slow down the rotation a little.
Title: Re: Rotating Banners
Post by: AdviseorAnswers.com on November 21, 2007, 03:18:25 PM
Quote from: Ghostwriter on February 26, 2007, 06:12:46 PM
I was just wondering how to slow down the rotation a little.
Locate this:

setTimeout("bannerRotate()", 3000);

Change the 3000. A higher number to slow the rotation, lower number will speed up the rotation
Title: Re: Rotating Banners
Post by: virtualdave on May 22, 2008, 08:14:03 PM
This is working in a test block just fine for me in IE. I added the target=\"_blank\" to this and would like to make one other change. Perhaps someone here would know how to do this. I would like to be able to use banners of differing dimensions in the rotation. I can change the display size for the individual banners settings so they display accuratly but this results in the overall size of the display box jumping up and down in size. Is there a way to make the box stay one size, that is large enough to accommodate my largest banner? Then, have the smaller sizes display centered within this space?
Title: Re: Rotating Banners
Post by: b33znutz on June 05, 2008, 03:53:09 AM
anyone know the fix for the firefox issue? i to got it to work great (thanks rose!)... only when i render with IE though.... i would like to use this myself, so i am actively searching...
Title: Re: Rotating Banners
Post by: Rebecca on September 20, 2008, 04:05:20 PM
Hi Guys,

Does anyone have a fix for this to work on FF?

Cheers :)
Title: Re: Rotating Banners
Post by: IchBin on September 20, 2008, 08:34:25 PM
I don't know javascript very well, but try replacing this function:
function bannerRotate() {

if(myCount > bannerArray.length-1){myCount=0;}

// Write out rotation
if (document.all){ // it is IE
document.all.l3.innerHTML=bannerArray[myCount];
}

else if (document.layers){ // it is NN

document.layers.l1.document.layers.l2.document.open();
document.layers.l1.document.layers.l2.document.write(bannerArray[myCount]);
document.layers.l1.document.layers.l2.document.close();
}
setTimeout("bannerRotate()", 3000);
myCount++;
}



If that doesn't work, I don't know what to tell you.
with this code;
function bannerRotate() {
    if(myCount > bannerArray.length-1){myCount=0;}
        document.getElementById("l3").innerHTML=bannerArray[myCount];
        setTimeout("bannerRotate()", 3000);
        myCount++;
}
Title: Re: Rotating Banners
Post by: Rebecca on September 21, 2008, 02:06:59 AM
Hi IchBin,

Doesnt work in either IE or FF. Thanks for trying, appreciate it :)
Title: Re: Rotating Banners
Post by: IchBin on September 21, 2008, 02:59:51 AM
Since I don't have the images nor the setup to trouble shoot this, if you'd like some help I'll need to look at it on your site. PM me a temp admin account if you'd like some help.
Title: Re: Rotating Banners
Post by: Rebecca on September 21, 2008, 03:07:14 AM
IchBin,

Just pm'd you. Thank you  :)
Title: Re: Rotating Banners
Post by: IchBin on September 21, 2008, 03:50:50 AM
Ok, that should be fixed. It appears they were using an "L" in the "l3" id. I was using a "1". :) The code above should work for everyone else as well.
Title: Re: Rotating Banners
Post by: Rebecca on September 21, 2008, 03:52:58 AM
IchBin,

Awesome they look great! Thank you so very much for your help. I really appreciate it! Thank you!!
Title: Re: Rotating Banners
Post by: jdvarner on November 10, 2008, 02:12:48 PM
Nice. Got it working good. Is it possible to also have it start random as well with the rotation. vs just going in order everytime?
Title: Re: Rotating Banners
Post by: Itch on November 10, 2008, 09:12:48 PM
That would be a completely different script. This is just a rotation banner, not a random banner. If you'd like that, I'm sure you could find something with a google search. Bring the script here, and we can help possibly.
Title: Re: Rotating Banners
Post by: phpshiva on May 24, 2009, 03:49:21 PM
This doesent work for me if i want that to add in a block and take html javascript whit new install of TP 1.075 the script doesent work at any java code i use in there