
25/11/2015, 06:59
|
 | Colaborador | | Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 16 años, 8 meses Puntos: 1012 | |
Respuesta: Enlace aleatorio sin repetir a ver si es esto lo que pretendes Cita: function eventos() {
var variable = new variables();
document.querySelector('#redirecion').addEventList ener('click', function() { setTimeout(function() {variable.arr.aleatorio()}, 0) }, false);
variable.arr.aleatorio();
}
function variables() {
this.arr = ['http://www.google.com', 'http://www.bing.com', 'http://www.yahoo.com', 'http://www.hotmail.com'];
}
Array.prototype.aleatorio = function() {
if(!this.length) {document.location.reload();}
var ran = this.splice(Math.floor(Math.random() * this.length), 1);
document.querySelector('#redirecion').href = ran;
}
document.addEventListener('DOMContentLoaded', function() {eventos()}, false);
<a href="http://www.google.com" id="redirecion" target="blank">Ir a la web</a> |