Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][JAVA]losowe wyświetlanie banerów na blogu, kod php lub java
Kamil90
post
Post #1





Grupa: Zarejestrowani
Postów: 73
Pomógł: 0
Dołączył: 17.02.2008
Skąd: Toruń

Ostrzeżenie: (0%)
-----


Jak można zrobić na blogu wordpress, żeby wyświetlały się losowa 2 banery? znacie jakiś odpowiedni kod php lub java do tego?
Na przykład:
[kod php lub java]
kod banera 1
[kod php lub java]
kod banera 2
[kod php lub java]

i żeby losowo były wyświetlane 2 banery

Czekam na pomoc, oczywiście będzie +
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
K4mil94
post
Post #2





Grupa: Zarejestrowani
Postów: 302
Pomógł: 18
Dołączył: 10.03.2008
Skąd: Dębno

Ostrzeżenie: (0%)
-----


Google, Google i jeszcze raz Google. Pod frazą 'Rotator bannerów' jest pełno rozwiązań (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) Wystarczy trochę chęci (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Kod
<script LANGUAGE="javascript">
function banner(img_source,url,alt,chance) {
   this.img_source = img_source;
   this.url = url;
   this.alt = alt;
   this.chance = chance;
}
function display() {
   with (this) document.write("<A HREF=" + url + "><IMG SRC='" + img_source + "' WIDTH=400 HEIGHT=50 BORDER=0 ALT='" + alt + "'></A>");
}
banner.prototype.display = display;
banners = new Array();
banners[0] = new banner("http://adres_strony1/banner.gif",
                        "http://www.sdres_strony1 target='_blank'",
                        "nazwa strony1",
                        2);
banners[1] = new banner("http://adres_strony2/banner.gif",
                        "http://www.adres_strony2 target='_blank'",
                        "nazwa strony2",
                        1);
banners[2] = new banner("http://adres_strony3/banner.gif",
                        "http://www.adres_strony3 target='_blank'",
                        "nazwa strony3",
                        3);
sum_of_all_chances = 0;
for (i = 0; i < banners.length; i++) {
   sum_of_all_chances += banners[i].chance;
}
function display_banner() {
   chance_limit = 0;
   randomly_selected_chance = Math.round((sum_of_all_chances - 1) * Math.random()) + 1;
   for (i = 0; i < banners.length; i++) {
      chance_limit += banners[i].chance;
      if (randomly_selected_chance <= chance_limit) {
         document.write("<A HREF=" + banners[i].url + "><IMG SRC='" + banners[i].img_source + "' WIDTH=400 HEIGHT=50 BORDER=0 ALT='" + banners[i].alt + "'></A>");
         return banners[i];
         break;
      }
   }
}
//-->
</SCRIPT>

<script LANGUAGE="javascript">
<!--
top_banner = display_banner();
//-->
</SCRIPT>


Ten post edytował K4mil94 29.03.2009, 08:14:34
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 11.10.2025 - 09:08