hello,
I have a problem with this piece of code. I want to open a random web page
each time and remember which one has been opened before because I don´t want
to repeat. It works fine the first 3 or 4 times, but after that, it gets
collapsed and i have to close the window. Any advice?
<script language="javascript">
// numero de ejercicios que componen todo. all the exercises
var numero_de_ejercicios=10;
// ejercicios ya salidos showed exercises
var ej_salidos=new Array(numero_de_ejercicios);
for (var i=0; i<ej_salidos.length;i++)
{ ej_salidos[i]=0;}
function ej_aleat(maximo,salidos){
var azar=100;
var ej_salido=0;
// repite mientras salga el 0, uno mayor que no exista o uno repetido
// repites while num_ej=0 (that page doesn´t exists), num_ej greater than
max number of exercise o i get one repeated
do{
var num_ej=Math.floor(azar*Math.random());
if(salidos[num_ej]==1)
{ej_salido=1}
}
while(((num_ej>maximo)||(num_ej==0))||(ej_salido== 1));
if(num_ej<100){
var dir='ejercicio00'+num_ej+'.htm'}
else if (num_ej>99){
var dir='ejercicio'+num_ej+'.htm'}
else{
var dir='ejercicio0'+num_ej+'.htm'}
window.open(dir);
ej_salidos[num_ej]=1;
}
</script>
<h3 class="ejercicio"><a href="#"
onClick='ej_aleat(numero_de_ejercicios,ej_salidos) ;'>Ejercicios
aleatorios.</a> </h3>