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.

New image in every refresh.

2 posters

Go down

New image in every refresh. Empty New image in every refresh.

Post by Mix4lis 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
Mix4lis
New Member

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

Back to top Go down

New image in every refresh. Empty Re: New image in every refresh.

Post by Sr.Smith 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
Sr.Smith
Forumember

Posts : 94
Reputation : 11
Language : Spanish

Back to top Go down

New image in every refresh. Empty Re: New image in every refresh.

Post by Mix4lis 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
Mix4lis
New Member

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

Back to top Go down

New image in every refresh. Empty Re: New image in every refresh.

Post by Sr.Smith 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
Sr.Smith
Forumember

Posts : 94
Reputation : 11
Language : Spanish

Back to top Go down

New image in every refresh. Empty Re: New image in every refresh.

Post by Mix4lis 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
Mix4lis
New Member

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

Back to top Go down

Back to top


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