Foros del Web » Programando para Internet » Javascript »

Veis algun fallo en este codigo:

Estas en el tema de Veis algun fallo en este codigo: en el foro de Javascript en Foros del Web. lo dicho si veis algun fallo, porque debe salir cualquiera de los 18 al azar, pero no se porque los dos ultimos nunca salen. A ...
  #1 (permalink)  
Antiguo 18/12/2007, 17:51
 
Fecha de Ingreso: diciembre-2007
Mensajes: 13
Antigüedad: 16 años, 4 meses
Puntos: 0
Veis algun fallo en este codigo:

lo dicho si veis algun fallo, porque debe salir cualquiera de los 18 al azar, pero no se porque los dos ultimos nunca salen.

A ver si estoy loco o hay algun fallo, muchas gracias de antemano ;)

<html><head><title>PARTICOTAKU</title>
<style type="text/css">
<!--
.style1 {
font-size: 24px;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
color: #0000FF;
}
-->
</style>
</head><SCRIPT>
var number=18;
var random_number=0;
link = new Array(18);
link[0] = "tabu/tabu 1.html";
link[1] = "tabu/tabu 2.html";
link[2] = "tabu/tabu 3.html";
link[3] = "tabu/tabu 4.html";
link[4] = "tabu/tabu 5.html";
link[5] = "tabu/tabu 6.html";
link[6] = "tabu/tabu 7.html";
link[7] = "tabu/tabu 8.html";
link[8] = "tabu/tabu 9.html";
link[9] = "tabu/tabu 10.html";
link[10] = "tabu/tabu 11.html";
link[11] = "tabu/tabu 12.html";
link[12] = "tabu/tabu 13.html";
link[13] = "tabu/tabu 14.html";
link[14] = "tabu/tabu 15.html";
link[15] = "tabu/tabu 16.html";
link[16] = "tabu/tabu 17.html";
link[17] = "tabu/tabu 18.html";

function loadRandomPage()
{
today=new Date();
jran=today.getTime();
ia=9301;
ic=49297;
im=233280;
jran = (jran*ia+ic) % im;
random_number=Math.ceil( (jran/(im*1.0)) *number);
if (window.parent)
window.parent.location=link[random_number-1];
else
window.location=link[random_number-1];
}
function viewSource()
{
var current_url="";
current_url=document.location;
window.location="view-source:"+current_url;
}
function WinOpen()
{
alert('\nLa pagina se cargará en ventana completa.\n\n');
window.open("tu_pagina.htm","DisplayWindow","menub ar=yes,scrollbars=yes");
window.open("tu_pagina.htm","DisplayWindow","menub ar=yes,scrollbars=yes");
}
</SCRIPT><body background="imagenes/fondos/back08.jpg">
<div align="center">

<center>
<INPUT TYPE="button" VALUE="Pulsa para otra pregunta al azar" onClick="loadRandomPage()">
</div>
</body></html>

Última edición por juanoide; 18/12/2007 a las 19:48
  #2 (permalink)  
Antiguo 19/12/2007, 12:12
 
Fecha de Ingreso: diciembre-2007
Mensajes: 13
Antigüedad: 16 años, 4 meses
Puntos: 0
Re: Veis algun fallo en este codigo:

podria responderme alguien....
  #3 (permalink)  
Antiguo 20/12/2007, 07:36
 
Fecha de Ingreso: diciembre-2007
Mensajes: 13
Antigüedad: 16 años, 4 meses
Puntos: 0
Re: Veis algun fallo en este codigo:

gracias...
  #4 (permalink)  
Antiguo 20/12/2007, 07:47
Avatar de agressor  
Fecha de Ingreso: noviembre-2007
Ubicación: Knocking the Death Door..
Mensajes: 368
Antigüedad: 16 años, 5 meses
Puntos: 3
Re: Veis algun fallo en este codigo:

Pues la verdad no que yo pueda observar errores de sintaxis no.. solo que no se para que llamas 2 ventanas al mismo tiempo..? mmm no te sabria decir con exactitud pero voy probar a ver..
  #5 (permalink)  
Antiguo 20/12/2007, 07:54
Avatar de agressor  
Fecha de Ingreso: noviembre-2007
Ubicación: Knocking the Death Door..
Mensajes: 368
Antigüedad: 16 años, 5 meses
Puntos: 3
Re: Veis algun fallo en este codigo:

Aqui hay un ejemplo para obtener un nunmero aleatorio entre dos valores tal vez te sirva.. espero te ayude..

http://skindario.com/768844/5489511-...s-math-random/

Prueba y me cuentas..

Salu2..!!
  #6 (permalink)  
Antiguo 20/12/2007, 13:38
 
Fecha de Ingreso: diciembre-2007
Mensajes: 13
Antigüedad: 16 años, 4 meses
Puntos: 0
Re: Veis algun fallo en este codigo:

pero que tendría que cambiar (~)
  #7 (permalink)  
Antiguo 20/12/2007, 14:02
Avatar de agressor  
Fecha de Ingreso: noviembre-2007
Ubicación: Knocking the Death Door..
Mensajes: 368
Antigüedad: 16 años, 5 meses
Puntos: 3
De acuerdo Re: Veis algun fallo en este codigo:

Intenta con esto no lo he probado pero quiza te funcione...

function loadRandomPage()
{superior=18;
inferior=0;
numPosibilidades = superior - inferior
aleat = Math.random() * numPosibilidades
aleat = Math.round(aleat)
random_number= parseInt(inferior) + aleat ;
if (window.parent)
window.parent.location=link[random_number-1];
else
window.location=link[random_number-1];
}
function viewSource()
{
var current_url="";
current_url=document.location;
window.location="view-source:"+current_url;
}
function WinOpen()
{
alert('\nLa pagina se cargará en ventana completa.\n\n');
window.open("tu_pagina.htm","DisplayWindow","menub ar=yes,scrollbars=yes");
window.open("tu_pagina.htm","DisplayWindow","menub ar=yes,scrollbars=yes");
}
</SCRIPT><body background="imagenes/fondos/back08.jpg">
<div align="center">

<center>
<INPUT TYPE="button" VALUE="Pulsa para otra pregunta al azar" onClick="loadRandomPage()">
</div>
</body></html>

Espero te sirva..
Prueba y me cuentas..!

Salu2..!
  #8 (permalink)  
Antiguo 23/12/2007, 15:11
 
Fecha de Ingreso: diciembre-2007
Mensajes: 13
Antigüedad: 16 años, 4 meses
Puntos: 0
Re: Veis algun fallo en este codigo:

nose que le pasa a tu codigo pero de vez en cuando se carga una pagina llamada undefined.

(~)
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:51.