Advertise Here

Author Topic: [Code] Alternating Banners  (Read 6322 times)

0 Members and 1 Guest are viewing this topic.

Offline carpaddict13

  • SMF For Free Newbie
  • *
  • Posts: 18
    • View Profile
    • trench

  • Total Badges: 14
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
[Code] Alternating Banners
« on: March 24, 2007, 10:02:38 am »
Forum Url: http://trench.smfforfree2.com
Is there a code that will allow me to repeatedly alternate from one banner to another and back again ?

Any help or advice appreciated
« Last Edit: August 27, 2007, 09:07:20 pm by simply sibyl »

Offline Crasy

  • Global Moderator
  • *
  • Posts: 3960
  • Semi-Retired ;)
    • View Profile

  • Total Badges: 29
    Badges: (View All)
    Poll Starter Poll Voter Seventh year Anniversary Arcade Highscore Windows User
Re: Alternating Banners
« Reply #1 on: March 24, 2007, 11:46:30 am »
Here's a script I nabbed from http://www.java-scripts.net

Code: [Select]
<script language="JavaScript">
<!--
/*
Random Image Link Script
By Website Abstraction (http://www.wsabstract.com)
and Java-scripts.net (http://www.java-scripts.net)
*/

function random_imglink(){
  var myimages=new Array()
  //specify random images below. You can have as many as you wish
  myimages[1]="img1.gif"
  myimages[2]="img2.gif"

  //specify corresponding links below
  var imagelinks=new Array()
  imagelinks[1]=""
  imagelinks[2]=""

  var ry=Math.floor(Math.random()*myimages.length)

  if (ry==0)
     ry=1
     document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')
}

  random_imglink()
//-->
</script>

Just replace img1.gif and img2.gif with two separate images. It will randomly select one and display it on each page load.
Did my answer help you? Want to help out hosting costs?


Every donation counts.

Offline carpaddict13

  • SMF For Free Newbie
  • *
  • Posts: 18
    • View Profile
    • trench

  • Total Badges: 14
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Alternating Banners
« Reply #2 on: March 24, 2007, 12:20:50 pm »
sorted thanks a million  ;)
« Last Edit: March 24, 2007, 12:26:45 pm by carpaddict13 »

Offline coke

  • SMF For Free Full Member
  • *
  • Posts: 148
    • View Profile

  • Total Badges: 14
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Alternating Banners
« Reply #3 on: April 29, 2007, 09:19:55 pm »
Could this be changed for backgrounds of forums that are fixed?

Offline Kimmie

  • SMF For Free Master
  • *
  • Posts: 2010
    • View Profile
    • Kimmie's Caverns

  • Total Badges: 19
    Badges: (View All)
    Topic Starter Combination Level 4 Level 3 Level 2
Re: Alternating Banners
« Reply #4 on: April 29, 2007, 11:39:07 pm »
Quote

Just replace img1.gif and img2.gif with two separate images. It will randomly select one and display it on each page load.

in addition to changing "img1" and "img2", dont you have to put the urls of the images inside the quotes here? (just want to make sure before I actually try this..lol)

Code: [Select]
//specify corresponding links below
  var imagelinks=new Array()
  imagelinks[1]=""
  imagelinks[2]=""




Offline carpaddict13

  • SMF For Free Newbie
  • *
  • Posts: 18
    • View Profile
    • trench

  • Total Badges: 14
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Alternating Banners
« Reply #5 on: April 30, 2007, 02:00:29 am »
This is what I have done and it works fine

function random_imglink(){
  var myimages=new Array()
    myimages[1]="http://i111.photobucket.com/albums/n131/carpaddict13/cooltext49413267.gif"
  myimages[2]="http://i111.photobucket.com/albums/n131/carpaddict13/cooltext49431622.gif"
  myimages[3]="http://i111.photobucket.com/albums/n131/carpaddict13/BAN1.jpg"
  myimages[4]="http://i111.photobucket.com/albums/n131/carpaddict13/cooltext49431543.gif"
  myimages[5]="http://i111.photobucket.com/albums/n131/carpaddict13/BAN2.jpg"
 
  var imagelinks=new Array()
  imagelinks[1]="http://i111.photobucket.com/albums/n131/carpaddict13/cooltext49431543.gif"
  imagelinks[2]="http://i111.photobucket.com/albums/n131/carpaddict13/cooltext49413267.gif"
  imagelinks[3]="http://i111.photobucket.com/albums/n131/carpaddict13/cooltext49431622.gif"
  imagelinks[4]="http://i111.photobucket.com/albums/n131/carpaddict13/BAN2.jpg"
  imagelinks[5]="http://i111.photobucket.com/albums/n131/carpaddict13/BAN1.jpg"
  var ry=Math.floor(Math.random()*myimages.length)

  if (ry==0)
     ry=1
     document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0>')
}

  random_imglink()
//-->

Offline coke

  • SMF For Free Full Member
  • *
  • Posts: 148
    • View Profile

  • Total Badges: 14
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Alternating Banners
« Reply #6 on: April 30, 2007, 02:53:09 am »
how would you make those into a fixed background?

Offline Kimmie

  • SMF For Free Master
  • *
  • Posts: 2010
    • View Profile
    • Kimmie's Caverns

  • Total Badges: 19
    Badges: (View All)
    Topic Starter Combination Level 4 Level 3 Level 2
Re: Alternating Banners
« Reply #7 on: April 30, 2007, 03:00:41 am »
how would you make those into a fixed background?

I wouldnt think it would affect your background.. your putting that code in your headers not your css code. (could be wrong tho..lol)

edit---or are you wanting it to alternate backgrounds?
« Last Edit: April 30, 2007, 03:04:55 am by Kimmieb »

Offline carpaddict13

  • SMF For Free Newbie
  • *
  • Posts: 18
    • View Profile
    • trench

  • Total Badges: 14
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Alternating Banners
« Reply #8 on: April 30, 2007, 11:20:15 am »
I have that code in my headers and it dosnt effect the background

Offline coke

  • SMF For Free Full Member
  • *
  • Posts: 148
    • View Profile

  • Total Badges: 14
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Alternating Banners
« Reply #9 on: April 30, 2007, 01:45:47 pm »
Yeah I want alternating backgrounds

Offline Crasy

  • Global Moderator
  • *
  • Posts: 3960
  • Semi-Retired ;)
    • View Profile

  • Total Badges: 29
    Badges: (View All)
    Poll Starter Poll Voter Seventh year Anniversary Arcade Highscore Windows User
Re: Alternating Banners
« Reply #10 on: April 30, 2007, 02:07:17 pm »
We don't have a code for that, sorry.
Did my answer help you? Want to help out hosting costs?


Every donation counts.

Offline coke

  • SMF For Free Full Member
  • *
  • Posts: 148
    • View Profile

  • Total Badges: 14
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Alternating Banners
« Reply #11 on: April 30, 2007, 06:04:44 pm »
I would think that the banner code could just be modified in order to make it into backgrounds instead of banners that would change with each page view, there's a code on help4admins.com, under the scripts section, that allows the page to change at certain times of the day, but how do you get it to do that with every page visit?

Offline Crasy

  • Global Moderator
  • *
  • Posts: 3960
  • Semi-Retired ;)
    • View Profile

  • Total Badges: 29
    Badges: (View All)
    Poll Starter Poll Voter Seventh year Anniversary Arcade Highscore Windows User
Re: Alternating Banners
« Reply #12 on: April 30, 2007, 06:23:48 pm »
I would think that the banner code could just be modified in order to make it into backgrounds instead of banners that would change with each page view, there's a code on help4admins.com, under the scripts section, that allows the page to change at certain times of the day, but how do you get it to do that with every page visit?

I'm going to take a shot in the woods at this one.
I don't know much about javascript..so if it doesn't work I wouldn't be surprised.
Try this:
Code: [Select]
<script language="JavaScript">
<!--
/*
Random Image Link Script
By Website Abstraction (http://www.wsabstract.com)
and Java-scripts.net (http://www.java-scripts.net)
*/

function random_imglink(){
  var myimages=new Array()
  //specify random images below. You can have as many as you wish
  myimages[1]="img1.gif"
  myimages[2]="img2.gif"

  //specify corresponding links below
  var imagelinks=new Array()
  imagelinks[1]=""
  imagelinks[2]=""

  var ry=Math.floor(Math.random()*myimages.length)

  if (ry==0)
     ry=1
     document.write('<style type="text/css">
body {background-image: url("'+myimages[ry]+'")}
</style>')
}

  random_imglink()
//-->
</script>

Put the background images into 'myimages'
Did my answer help you? Want to help out hosting costs?


Every donation counts.

Offline coke

  • SMF For Free Full Member
  • *
  • Posts: 148
    • View Profile

  • Total Badges: 14
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Alternating Banners
« Reply #13 on: April 30, 2007, 07:40:25 pm »
It doesn't seem to work.

Offline Crasy

  • Global Moderator
  • *
  • Posts: 3960
  • Semi-Retired ;)
    • View Profile

  • Total Badges: 29
    Badges: (View All)
    Poll Starter Poll Voter Seventh year Anniversary Arcade Highscore Windows User
Re: Alternating Banners
« Reply #14 on: April 30, 2007, 07:52:01 pm »
I tried playing around with it some more. You're right, it doesn't work.

Sorry, I can't help then at all.
Did my answer help you? Want to help out hosting costs?


Every donation counts.

 

Related Topics

  Subject / Started by Replies Last post
8 Replies
1821 Views
Last post March 17, 2007, 04:36:52 pm
by Simply The Best
4 Replies
1540 Views
Last post May 26, 2007, 09:11:35 pm
by mimi
4 Replies
1715 Views
Last post July 04, 2007, 07:19:14 am
by phat owner
5 Replies
1124 Views
Last post September 16, 2007, 11:02:48 pm
by Coreeeey
3 Replies
3272 Views
Last post August 01, 2009, 07:24:14 am
by Tretispker