← Desenvolvimento

Random banner javascript

Lida 4944 vezes

Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Porque raio é que isto não funcemina?

Código: [Seleccione]
<script language="JavaScript">
var max = 10;
var nrImages = 4;
function makeImages() {
this[0] = "http://i34.photobucket.com/albums/d109/cenourinha/1b02790f.gif";
this[1] = "http://i34.photobucket.com/albums/d109/cenourinha/1b02790f.gif";
this[2] = "http://i34.photobucket.com/albums/d109/cenourinha/1b02790f.gif";
this[3] = "http://i34.photobucket.com/albums/d109/cenourinha/1b02790f.gif"";
this[4] = "http://bogasnetworks.com.sapo.pt/gethost4you_big_banner.gif";
this.length = nrImages;
}
function makeLinks() {
this[0] = "http://www.webtuga.com/index.php";
this[1] = "http://www.webtuga.com/top/index.php";
this[2] = "http://www.webtuga.com/forum/viewtopic.php?t=7363";
this[3] = "http://www.mais-trafego.info";
this[4] = "http://www.gethost4you.com";
this.length = nrImages;

}
var vetImages = new makeImages();
var vetLinks = new makeLinks();
var x = Math.round(Math.random()*max);
var y = max / nrImages;
for(var cont = 1;cont*y<= max;cont++) {
if (x <= (cont*y)) {
document.write("<a href="+vetLinks[cont-1]+" target=_blank><img src="+vetImages[cont-1]+" border="0" width="460" height="60"></a>");
break;
}
}
</script>
Offline

Ricardo75 
Membro
Mensagens 1660 Gostos 0
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

no endereço da 4ª imagem tens 2 vezes " a terminar a linha

e no document.write só podes usar aspas " para separar o html das funções, para colocares os parâmetros do html tens de usar plicas '
Código: [Seleccione]
<script language="JavaScript">
var max = 10;
var nrImages = 4;
function makeImages() {
this[0] = "http://i34.photobucket.com/albums/d109/cenourinha/1b02790f.gif";
this[1] = "http://i34.photobucket.com/albums/d109/cenourinha/1b02790f.gif";
this[2] = "http://i34.photobucket.com/albums/d109/cenourinha/1b02790f.gif";
this[3] = "http://i34.photobucket.com/albums/d109/cenourinha/1b02790f.gif";
this[4] = "http://bogasnetworks.com.sapo.pt/gethost4you_big_banner.gif";
this.length = nrImages;
}
function makeLinks() {
this[0] = "http://www.webtuga.com/index.php";
this[1] = "http://www.webtuga.com/top/index.php";
this[2] = "http://www.webtuga.com/forum/viewtopic.php?t=7363";
this[3] = "http://www.mais-trafego.info";
this[4] = "http://www.gethost4you.com";
this.length = nrImages;

}
var vetImages = new makeImages();
var vetLinks = new makeLinks();
var x = Math.round(Math.random()*max);
var y = max / nrImages;
for(var cont = 1;cont*y<= max;cont++) {
if (x <= (cont*y)) {
document.write("<a href="+vetLinks[cont-1]+" target=_blank><img src="+vetImages[cont-1]+" border='0'/></a>");
break;
}
}
</script>


Já aparece qualquer coisa, apesar de achar que não é só isso que queres... o que é que isto devia fazer?
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Era para por um banner randonomico na footer do Fórum phpbb do WebTuga.
Funcionou, muito obrigado.
Offline

Pure_Water 
Membro
Mensagens 515 Gostos 0
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1 500 Posts

nao se diz randonomico, diz-se aleatório lol
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

é o vicio do rand()

xD
Offline

kingless 
Membro
Mensagens 857 Gostos 0
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2 Level 1

Acho que é mais fácil fazer isso com PHP pelo menos para mim é maisl facil porque não sei Javascript.
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Pois, mas como é para por no phpbb eu prefiro assim.
Offline

Nazgulled 
Membro
Mensagens 552 Gostos 0
Troféus totais: 29
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

randonomico. lolololololol... curti, de mais, grande palavra lol :P ms ja ta a funcionar ou queres ajuda?
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Offline

kingless 
Membro
Mensagens 857 Gostos 0
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2 Level 1

O webtuga já está DOWN desde ontem...
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

É a WebLusa.
Offline

Miguel Lucas 
Elite
Mensagens 3619 Gostos 16
Feedback +14

Troféus totais: 35
Trófeus: (Ver todos)
Level 6 Windows User Linux User Mobile User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter

eu uso este script no meu site...para quem não perceber do quee stá ali em cima...

Código: [Seleccione]

<script language="JavaScript">

images = new Array(1);

images[0] = "<a href = 'http://www.dsdsd.pt'><img src='http://sdsdsdsdsdsdsdsd.jpg' alt='Nome'></a>";

images[1] = "<a href = 'http://www.sdsdsdsd.org'><img src='http://sdsdsdsdsdsjpg' alt='Nome'></a>";

index = Math.floor(Math.random() * images.length);

document.write(images[index]);
</script>
Offline

[A]visaPT 
Membro
Mensagens 256 Gostos 0
Troféus totais: 26
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Level 5 Level 4 Level 3 Level 2 Level 1 100 Posts 50 Posts

Se eu quiser adicionar agora ai um script tipo o do adsense como faço?
ou do bwin que são deste genero:
Código: [Seleccione]
<iframe id="betandwinad" name="betandwinad" src="http://adserver.itsfogo.com/default.aspx?t=f&v=1&zoneid=22603" framespacing="0" frameborder="no" scrolling="no" width="468" height="60" allowtransparency="true"><ilayer width="468" height="60"><layer src="http://adserver.itsfogo.com/default.aspx?tli&v=1&zoneid=22603"></layer></ilayer><nolayer><a href="http://adserver.itsfogo.com/click.aspx?t=i&v=1&zoneid=22603" target="betandwin"><img src="http://adserver.itsfogo.com/default.aspx?t=i&v=1&zoneid=22603" border="0" alt=""></a></nolayer></iframe>
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Substituis todos os " por ' e depois colocas em vez de <a href = 'http://www.sdsdsdsd.org'><img src='http://sdsdsdsdsdsjpg' alt='Nome'></a>
Offline

[A]visaPT 
Membro
Mensagens 256 Gostos 0
Troféus totais: 26
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Level 5 Level 4 Level 3 Level 2 Level 1 100 Posts 50 Posts

Vou tentar tks :wink: