SMF For Free Support Forum

SMF For Free Support => SMF For Free Codes and Support => Topic started by: Agent Moose on August 14, 2007, 10:23:28 pm

Title: [Code] Random Banner
Post by: Agent Moose on August 14, 2007, 10:23:28 pm
Code: [Select]
<script>
var randbanner = []
//Created by Agent Moose (smcodes.smfforfree3.com)
randbanner[0]=["URL"]

rawr = Math.floor(Math.random()*randbanner.length)
document.write("<center><img src='" + randbanner[rawr][0] + "' /></center>")
</script>
Place it where ever you want your banners to show.
URL = the URL of the image

To add more, just add more of these lines:
randbanner[0]=["URL"]

Change the 0 to a 1, if you add another line after that, you would change the 1 to a 2.
Title: Re: Random Banner
Post by: LaundryLady on August 15, 2007, 05:54:15 am
Thanks, Moose, sounds cool.  As soon as I can figure out what I want will give it a try.
Title: Re: Random Banner
Post by: nitsua on August 15, 2007, 06:22:23 pm
can i do a directory of images instead of a specific image
Title: Re: Random Banner
Post by: Agent Moose on August 16, 2007, 05:39:43 pm
No.  You have to use the URL of the whole image.
Title: Re: Random Banner
Post by: nitsua on August 18, 2007, 08:23:26 pm
k k
Title: Re: [Code] Random Banner
Post by: squal on September 12, 2007, 01:48:34 am
where i put this code?
Title: Re: [Code] Random Banner
Post by: simply sibyl on September 12, 2007, 05:55:36 am
where i put this code?

Admin > Manage Styles > Edit Header/Footer

Put it in your Header if you want it above the forum,  footer if you want it below the forum.   
Title: Re: [Code] Random Banner
Post by: stefun8 on March 29, 2008, 05:43:07 am
do u want to put a preview plzzz.


Thanks.
Title: Re: [Code] Random Banner
Post by: -Sя.Sharp on March 29, 2008, 12:10:21 pm
http://randombanner.smfforfree3.com/index.php
Keep refreshing the page to see em.
The banners i just found....
Title: Re: [Code] Random Banner
Post by: Chico on October 19, 2008, 01:23:39 am
Is there a way to make the banners clickable with this code?
Title: Re: [Code] Random Banner
Post by: Shimmy Shabby on November 01, 2008, 04:30:53 pm
[quote ]
Is there a way to make the banners clickable with this code?
[/quote]

Use this for each banner

Code: [Select]
randbanner[0]=["URL OF IMAGE' onclick=location.href='URL OF SITE' style='cursor: pointer"]
Title: Re: [Code] Random Banner
Post by: Chico on November 02, 2008, 01:38:27 am
Thanks , That works.
Title: Re: [Code] Random Banner
Post by: pancakes991 on November 28, 2008, 10:39:08 pm
thats cool
Title: Re: [Code] Random Banner
Post by: taogem on February 18, 2009, 06:49:49 pm
Forum Url: http://gemstone.smfforfree4.com/.smfforfree4.com
I looked through the list of codes, but can't figure out which one I might use to be able and place this code so that it shows in between a couple of the forums boards on the forum.

Can someone point me to how I might be able to do this... ?
Title: Re: [Code] Random Banner
Post by: simply sibyl on February 18, 2009, 07:25:44 pm
hi tao -   some scripts can be put in a Boards Description area just fine.. Ild always try it on a test forum first though and not your real forum.    Mentioning that as Im not sure what you mean by  "between a couple of the forums boards"   If you meant in the space between Categorys I know of no way to do that.
Title: Re: [Code] Random Banner
Post by: taogem on February 18, 2009, 07:35:26 pm
   If you meant in the space between Categorys I know of no way to do that.

Yes..... Categories is what I should have said.

Ok and thank you..
Title: Re: [Code] Random Banner
Post by: Pan on May 18, 2009, 10:41:17 pm
Thanks and it's center. thank you!
Title: Re: [Code] Random Banner
Post by: taogem on January 03, 2010, 04:11:20 am
Not sure what I am missing..

Here is an example of what I am placing within my Header and nothing shows up..

Code: [Select]

<script>
var randbanner = []
//Created by Agent Moose (smcodes.smfforfree3.com)
randbanner[0]=["http://farm3.static.flickr.com/2119/1683360334_283534ea14_o.jpg' onclick=location.href='http://taogem.com/taogemst_myzencart/" ' style='cursor: pointer"]
randbanner[1]=["http://farm2.static.flickr.com/1254/906421054_78113b1c8f_o.jpg' onclick=location.href='http://griffincustomopal.com/store/' style='cursor: pointer"]
randbanner[0]=["http://i517.photobucket.com/albums/u340/taogemstones/Bobs_premium_cabs-1.jpg' onclick=location.href='http://bobspremiumcabochons.com/"><' style='cursor: pointer"]

rawr = Math.floor(Math.random()*randbanner.length)
document.write("<center><img src='" + randbanner[rawr][0] + "' /></center>")
</script><p>

Title: Re: [Code] Random Banner
Post by: taogem on January 04, 2010, 04:27:56 am
Forum Url: http://gemstone.smfforfree4.com/
I made a couple of changes after looking at the page source for the example link showing what this looks like (http://randombanner.smfforfree3.com/index.php). Added some quotation marks and also numbered the images starting with 1 instead of zero..

Still not showing up for me when I try to add it to either the header or footer.

Help ?  :)

Code: [Select]

<script>
var randbanner = []
//Created by Agent Moose (smcodes.smfforfree3.com)
randbanner[1]=["http://farm3.static.flickr.com/2119/1683360334_283534ea14_o.jpg" onclick=location.href="http://taogem.com/taogemst_myzencart/" ' style='cursor: pointer"]
randbanner[2]=["http://farm2.static.flickr.com/1254/906421054_78113b1c8f_o.jpg" onclick=location.href="http://griffincustomopal.com/store/' style='cursor: pointer"]
randbanner[3]=["http://i517.photobucket.com/albums/u340/taogemstones/Bobs_premium_cabs-1.jpg" onclick=location.href="http://bobspremiumcabochons.com/"><' style='cursor: pointer"]

rawr = Math.floor(Math.random()*randbanner.length)
document.write("<center><img src='" + randbanner[rawr][0] + "' /></center>")
</script><p>

Title: Re: [Code] Random Banner
Post by: simply sibyl on January 04, 2010, 11:55:29 am
taogem -  you have it correct except you replaced some single quotes with double quotes and visa versa.
Ive corrected the code for you - this one works

Code: [Select]
<script>
var randbanner = []
//Created by Agent Moose (smcodes.smfforfree3.com)
randbanner[0]=["http://farm3.static.flickr.com/2119/1683360334_283534ea14_o.jpg' onclick=location.href='http://taogem.com/taogemst_myzencart/' style='cursor: pointer"]
randbanner[1]=["http://farm2.static.flickr.com/1254/906421054_78113b1c8f_o.jpg' onclick=location.href='http://griffincustomopal.com/store/' style='cursor: pointer"]
randbanner[2]=["http://i517.photobucket.com/albums/u340/taogemstones/Bobs_premium_cabs-1.jpg' onclick=location.href='http://bobspremiumcabochons.com/' style='cursor: pointer"]
rawr = Math.floor(Math.random()*randbanner.length)
document.write("<center><img src='" + randbanner[rawr][0] + "' /></center>")
</script>
Title: Re: [Code] Random Banner
Post by: taogem on January 04, 2010, 09:57:40 pm
That did the trick !!

Thanks a bunch !  :)
Title: Re: [Code] Random Banner
Post by: taogem on January 05, 2010, 02:23:35 am
Just one more question...

Is there a way to be able and right click on the banners so that they can be opened in a new page ?

Title: Re: [Code] Random Banner
Post by: taogem on January 05, 2010, 09:56:38 pm
Forum Url: http://gemstone.smfforfree4.com/
Another question members are asking..

Is there a way to have multiple banners show up at the same time during each page refresh ?  I am hoping from within the same script rather than multiple scripts ?

Also, would still like to know if there is something that can be done about being able to right click on the banners for opening in new page.
Title: Re: [Code] Random Banner
Post by: simply sibyl on January 05, 2010, 09:59:50 pm
hi tao  ;)      Unless someone else can figure out a way to tweak that code to do both things for you will have to wait on Moose to see this.   Now that he is off to college we don't see him as often Im afraid.
Title: Re: [Code] Random Banner
Post by: taogem on January 06, 2010, 09:35:10 pm
Okedokey..... !

I found another script online that is letting us right click on the random banners so as to open in a new page..  :)

Title: Re: [Code] Random Banner
Post by: taogem on May 04, 2014, 03:53:53 pm
Forum Url: http://gemstone.smfforfree4.com/
I would like to know if someone can make this code so that when someone clicks on the clickable banners, a new browser will open for that banners website so that they do not leave/loose the forum page..

Even if the banner could be "right clicked" to open in new window.  Even that could help..

Title: Re: [Code] Random Banner
Post by: taogem on May 05, 2014, 03:33:05 am
Forum Url: http://gemstone.smfforfree4.com/
I would like to know if someone can make this code so that when someone clicks on the clickable banners, a new browser will open for that banners website so that they do not leave/loose the forum page..

Even if the banner could be "right clicked" to open in new window.  Even that could help..



Anyone ?

Or am I posting this request in the wrong board ?
Title: Re: [Code] Random Banner
Post by: Agent Moose on May 17, 2014, 12:23:52 pm
Instead of using this, for example:
Code: [Select]
randbanner[0]=["http://farm3.static.flickr.com/2119/1683360334_283534ea14_o.jpg' onclick=location.href='http://taogem.com/taogemst_myzencart/' style='cursor: pointer"]
Try this:
Code: [Select]
randbanner[0]=["http://farm3.static.flickr.com/2119/1683360334_283534ea14_o.jpg' onclick='window.open(\"http://taogem.com/taogemst_myzencart/\")' style='cursor: pointer"]
Title: Re: [Code] Random Banner
Post by: taogem on May 17, 2014, 04:02:37 pm
Thank you !