Different Branding every time

Go down

In progress Different Branding every time

Post by J0k3R^ on June 26th 2014, 11:22 am

Hi, im using a branding on my forum but i want to make it change every time someone visits a new page in my forum.
If u check this: http://www.anime-greek.com/forums/index.php u will understand what i mean.. (just click again n again at their logo)

Male Posts : 742
Reputation : 28
Language : Greek > English > Russian > Spanish
Location : C:\>r00t


Back to top Go down

In progress Re: Different Branding every time

Post by Ange Tuteur on June 26th 2014, 12:04 pm


You can use JavaScript random math to pick a random banner to display.

Administration Panel > Modules > JavaScript codes management > Create a new script

Title : your choice
Placement : in all the pages
Paste the code below and save :
$(function() {
  var rand = Math.floor(Math.random() * 4);
  var logo = $('#logo img');
  if (rand === 0) logo.attr('src','/img.gif');
  if (rand === 1) logo.attr('src','/img.gif');
  if (rand === 2) logo.attr('src','/img.gif');
  if (rand === 3) logo.attr('src','/img.gif');

We set a range from 0 - 4, but not including 4. So, Math.floor(Math.random() * 4) will have a chance of 0, 1, 2, and 3. Increase the value of four and add more conditions to display a wider range of banners.

Also replace /img.gif by the URL of your image.
Ange Tuteur

Male Posts : 13202
Reputation : 2917
Language : EN10, FR5, JA5
Location : Macungie, PA


Back to top Go down

Back to top

Permissions in this forum:
You cannot reply to topics in this forum