The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

New image in every refresh.

View previous topic View next topic Go down

New image in every refresh.

Post by Mix4lis on September 22nd 2013, 11:33 am

Hello guys.

I want your help. How can i make my forum's banner change in every refresh? I mean, i want to add a lot of banners which will change when a member refresh a forum's page.

Thanks in advance Smile


Last edited by Mix4lis on September 26th 2013, 3:19 pm; edited 2 times in total

Mix4lis
New Member

Male Posts : 5
Reputation : 5
Language : Greek
Location : Athens

Back to top Go down

Re: New image in every refresh.

Post by Sr.Smith on September 22nd 2013, 11:51 am

Hi Mix4lis, add a new javascript, placement: In all pages


Code:
$(function(){
  var banner = new Array();
 
  banner[0] = "URL_banner_1";
  banner[1] = "URL_banner_2";
  banner[2] = "URL_banner_3";
  //if you need you can add more...

  function randombanner() {
  var randomnum= Math.floor(Math.random() * banner.length);
  $( "#pun-logo > img" ).attr("src", banner[randomnum]);
}
window.onload=randombanner;
  });
I hope this helps you

Sr.Smith
Forumember

Posts : 87
Reputation : 11
Language : Spanish

Back to top Go down

Re: New image in every refresh.

Post by Mix4lis on September 22nd 2013, 12:20 pm

Although i have Javascript enabled, it didn't work... I tried some javascript codes similar to the one you gave me, but they didn't work either. Do i have to change something else, except from the URL of the banners? For example, values?

Mix4lis
New Member

Male Posts : 5
Reputation : 5
Language : Greek
Location : Athens

Back to top Go down

Re: New image in every refresh.

Post by Sr.Smith on September 22nd 2013, 1:08 pm

No, you don't have to change other things, only the URL.

But what you say makes me think that you could have some error/s in your other javascripts. If you have an error in a javascript the other ones may don't work.

You can prove to export your other javascript for example to the notepad and prove this javascript alone.

Good luck.

Sr.Smith
Forumember

Posts : 87
Reputation : 11
Language : Spanish

Back to top Go down

Re: New image in every refresh.

Post by Mix4lis on September 23rd 2013, 7:45 pm

I had already removed all javascripts in case of errors, but it did't work.

Well, i'll give a try one more time.

Mix4lis
New Member

Male Posts : 5
Reputation : 5
Language : Greek
Location : Athens

Back to top Go down

View previous topic View next topic Back to top


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