Estoy intentando rotar hojas de CSS aleatorias a través de JS. Tengo el siguiente script, pero cuando lo estoy usando, ¿parece que no funciona?CSS aleatorio a través de JS
function getRand(){
return Math.round(Math.random()*(css.length-1));
}
var css = new Array(
'<link rel="stylesheet" type="text/css" href="css/1.css">',
'<link rel="stylesheet" type="text/css" href="css/2.css">',
'<link rel="stylesheet" type="text/css" href="css/3.css">',
'<link rel="stylesheet" type="text/css" href="css/4.css">'
);
rand = getRand();
document.write(css[rand]);
agradecería cualquier ayuda?
Funciona cuando lo intento. – Rob
hmm no estoy seguro - no funciona para mí :( –
¿quieres decirnos qué navegadores usas para probar esto? – erjiang