Ir para conteúdo
Fórum Script Brasil
  • 0

Qual O Erro?


c0de

Pergunta

Alguém pode me dizer qual o erro neste script?

é um sistema onde você tanto pode escolher um link de uma lista e clicar em "ir" para entrar no link, como clicar em "ir aleatóriamente" e entrar num link aleatório, como voces podem ver....

<html>
<head>
<title>teste</title>
<script language="javascript">
<!--
end = new Array(10);
end[0] = "http://www.alancarvalho.com.br";
end[1] = "http://www.uol.com.br";
end[2] = "http://www.terra.com.br";
end[3] = "http://www.cade.com.br";
end[4] = "http://www.yahoo.com.br";
end[5] = "http://www.globo.com";
end[6] = "http://www.estado.com.br";
end[7] = "http://www.brasil.gov.br";
end[8] = "http://www.radiobandeirantes.com.br";
end[9] = "http://www.sti.com.br";

tit = new Array(10);
tit[0] = "teste0";
tit[1] = "teste";
tit[2] = "teste1";
tit[3] = "teste2";
tit[4] = "teste3";
tit[5] = "teste4";
tit[6] = "teste5";
tit[7] = "teste6";
tit[8] = "teste7";
tit[9] = "teste8";

function Sorteio() {
numero = parseInt(Math.random() * 10);
if (isNaN(numero))
numero = 0;
location = end[numero];
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}
//-->
</script>
</head>
<body>
<script language="JavaScript">
<!--
document.write("<form name='form1'>");
document.write("<p><select name='teste'>");
for (i = 0;i < end.length;i++){
document.write("<option value='javascript:document.location.href="+end[i]+"'>"+tit[i]+"</option>");
}
document.write("</select>");
document.write("<input type='button' name='ir' value='Ir' onClick='MM_jumpMenuGo('teste','parent',0)'</p>");
document.write("</form><p><form name='form2' method='post' action=''><input type='submit' name='submit' value='Ir Aleatóriamente' onclick='Sorteio(form1.teste.selectedIndex)'></p>");
document.write("</form>");
-->
</script>
</body>
</html>

Link para o comentário
Compartilhar em outros sites

4 respostass a esta questão

Posts Recomendados

  • 0

Cara pra que isso tudo?E você fez do dreaweaver não foi?

Mas ae foi eu quem postou esse codigo aleatoriamento e o cara que pediu não reclamou.

Mas ae você pode trocar todo aquele codigo por esse

<html>

<head>

<title>teste</title>

<script language="javascript">

<!--

end = new Array(10);

end[0] = "http://www.alancarvalho.com.br";

end[1] = "http://www.uol.com.br";

end[2] = "http://www.terra.com.br";

end[3] = "http://www.cade.com.br";

end[4] = "http://www.yahoo.com.br";

end[5] = "http://www.globo.com";

end[6] = "http://www.estado.com.br";

end[7] = "http://www.brasil.gov.br";

end[8] = "http://www.radiobandeirantes.com.br";

end[9] = "http://www.sti.com.br";

tit = new Array(10);

tit[0] = "teste0";

tit[1] = "teste";

tit[2] = "teste1";

tit[3] = "teste2";

tit[4] = "teste3";

tit[5] = "teste4";

tit[6] = "teste5";

tit[7] = "teste6";

tit[8] = "teste7";

tit[9] = "teste8";

function Sorteio() {

numero = parseInt(Math.random() * 10);

if (isNaN(numero))

numero = 0;

location = end[numero];

}

//-->

</script>

</head>

<body>

<script language="JavaScript">

<!--

document.write('<form name="form1">')

document.write('<select name="op">')

for (i = 0;i < tit.length;i++){

document.write('<option value="'+end+'">'+tit+'</option>');

}

document.write('</select>')

document.write('<input type="button" name="jean" value="Ir" onclick="Sorteio()">')

document.write('</form>')

//-->

</script>

</body>

</html>

Se não funciona posta aqui

Link para o comentário
Compartilhar em outros sites

  • 0

tudo bem fica assim

<html>

<head>

<title>teste</title>

<script language="javascript">

<!--

end = new Array(10);

end[0] = "http://www.alancarvalho.com.br";

end[1] = "http://www.uol.com.br";

end[2] = "http://www.terra.com.br";

end[3] = "http://www.cade.com.br";

end[4] = "http://www.yahoo.com.br";

end[5] = "http://www.globo.com";

end[6] = "http://www.estado.com.br";

end[7] = "http://www.brasil.gov.br";

end[8] = "http://www.radiobandeirantes.com.br";

end[9] = "http://www.sti.com.br";

tit = new Array(10);

tit[0] = "teste0";

tit[1] = "teste";

tit[2] = "teste1";

tit[3] = "teste2";

tit[4] = "teste3";

tit[5] = "teste4";

tit[6] = "teste5";

tit[7] = "teste6";

tit[8] = "teste7";

tit[9] = "teste8";

function Sorteio() {

numero = parseInt(Math.random() * 10);

if (isNaN(numero))

numero = 0;

location = end[numero];

}

function Ir(valor) {

location = end[valor];

}

//-->

</script>

</head>

<body>

<script language="JavaScript">

<!--

document.write('<form name="form1">')

document.write('<select name="op">')

for (i = 0;i < tit.length;i++){

document.write('<option value="'+end+'">'+tit+'</option>');

}

document.write('</select>')

document.write('<input type="button" name="jean" value="Ir aleatoriamete" onclick="Sorteio()"><br>')

document.write('<input type="button" name="jack" value="Ir" onclick="Ir(document.form1.op.selectedIndex)">')

document.write('</form>')

//-->

</script>

</body>

</html>

Caso esteja errado posta aqui é que eu digitei aqui mesmo sem testar

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...