Skip to content

Instantly share code, notes, and snippets.

@kane-thornwyrd
Created May 18, 2012 11:50
Show Gist options
  • Save kane-thornwyrd/2724858 to your computer and use it in GitHub Desktop.
Save kane-thornwyrd/2724858 to your computer and use it in GitHub Desktop.
Fond de différentes couleurs "au hasard" en JS
couleurs = [
'ff0000'
'00ff00'
'0000ff'
]
m = Math
couleur_de_fond = couleurs[0]
cur = m.floor m.round m.random() * (couleurs.length - 1)
couleur_de_fond = couleurs[cur]
document.bgColor = couleur_de_fond
var couleur_de_fond, couleurs, cur, m;
couleurs = ['ff0000', '00ff00', '0000ff'];
m = Math;
couleur_de_fond = couleurs[0];
cur = m.floor(m.round(m.random() * (couleurs.length - 1)));
couleur_de_fond = couleurs[cur];
document.bgColor = couleur_de_fond;
<!DOCTYPE html>
<html>
<head>
<title>Fond de différentes couleurs &quot;au hasard&quot; en JS &mdash; Gist</title>
<script type="text/javascript">
var couleur_de_fond, couleurs, cur, m;
couleurs = ['ff0000', '00ff00', '0000ff'];
m = Math;
couleur_de_fond = couleurs[0];
cur = m.floor(m.round(m.random() * (couleurs.length - 1)));
couleur_de_fond = couleurs[cur];
document.bgColor = couleur_de_fond;
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment