vForums Support > Programming & Coding :: Code Requests & Support :: > [F] Random Banner Convert

[F] Random Banner Convert - Posted By dog199200 (dog199200) on 22nd Feb 08 at 10:22pm
Quote:
<script type="text/javascript"><!--
/* random banner
- open source */
var images = []; var n = 0;

images[n++] = 'Image URL 1';
images[n++] = 'Image URL 2';
images[n++] = 'Image URL 3';

var r = Math.floor(Math.random() * images.length);
document.getElementsByTagName('img').item(0).src = images[r];
//-->
</script>


Can someone please convert the random banner code please? {Smile}

Edit: and once it is open source can someone please make it so that it wont show the same image twice in a row?

Re: Random Banner Convert - Posted By FreeUS (freeus) on 23rd Feb 08 at 2:06am
It already works.As for the repeating thing.There isn't much you can do.

Re: Random Banner Convert - Posted By dog199200 (dog199200) on 23rd Feb 08 at 2:10am
no it don't work all the way, it doesn't put the images in the boards logo cell like it is suppose to, it put the images right on top of that

http://deluxeanimeforum.vforums.co.uk/

go there and refresh it till you see the image and see for yourself.

Re: Random Banner Convert - Posted By FreeUS (freeus) on 23rd Feb 08 at 3:02am
Hmm.Thats right.I forgot proboards has the banner on the left and I coded my forum to be like that.We'll,i'll see what I can do.

Re: Random Banner Convert - Posted By Michael (wrighty) on 23rd Feb 08 at 3:04am
Use this for now...

Can't make it NOT show the image twice sorry! {Sad}

Code:
 
  1. <script type="text/javascript"><!--
  2. /* random banner
  3. - open source */
  4. var images = []; var n = 0;
  5.  
  6. images[n++] = 'Image URL 1';
  7. images[n++] = 'Image URL 2';
  8. images[n++] = 'Image URL 3';
  9.  
  10. var r = Math.floor(Math.random() * images.length);
  11. get('welcome_table','id').getElementsByTagName('img')[0].src = images[r];
  12. //-->
  13. </script>
 

Re: Random Banner Convert - Posted By dog199200 (dog199200) on 23rd Feb 08 at 3:22am
its ok, and thanks that should work, but is there a way to make it seems as if it load with the rest of the forum and not after it? It looks tacky seeing it appear after the rest of the forum finishes loading.

Re: Random Banner Convert - Posted By FreeUS (freeus) on 23rd Feb 08 at 3:30am
The exact solution I was about to use.Well,Wrighty beat me to it.

Re: Random Banner Convert - Posted By Marc (cr0w) on 23rd Feb 08 at 6:01am
Posted By dog199200 on 23rd Feb 08 at 3:22am
 
its ok, and thanks that should work, but is there a way to make it seems as if it load with the rest of the forum and not after it? It looks tacky seeing it appear after the rest of the forum finishes loading.


Put it at the very top of your global header. {Wink}

Re: Random Banner Convert - Posted By dog199200 (dog199200) on 23rd Feb 08 at 6:04am
yay ty

Re: [f] Random Banner Convert - Posted By Marc (cr0w) on 23rd Feb 08 at 6:17am
Posted By dog199200 on 23rd Feb 08 at 6:04am
 
yay ty


No worries. {Smile}