The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Different Branding every time

2 posters

Go down

In progress Different Branding every time

Post by J0k3R^ Thu 26 Jun 2014 - 16:22

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)
J0k3R^
J0k3R^
Forumember

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

http://fmplanet.forumgreek.com

Back to top Go down

In progress Re: Different Branding every time

Post by Ange Tuteur Thu 26 Jun 2014 - 17:04

Hello,

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 :
Code:
$(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
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Back to top


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