Alternate Background


/ Published in: JavaScript
Save to your folder(s)

Alterar Background randomicamente.


Copy this code and paste it in your HTML
  1. <script type="text/javascript">
  2. var banner= new Array()
  3. banner[0]="Image01URL"
  4. banner[1]="Image02URL"
  5. banner[2]="Image03URL"
  6. banner[3]="Image04URL"
  7. banner[4]="Image05URL"
  8. banner[5]="Image06URL"
  9. banner[6]="Image07URL"
  10. banner[7]="Image08URL"
  11. banner[8]="Image09URL"
  12. banner[9]="Image10URL"
  13. var random=Math.floor(10*Math.random());
  14. document.write("<style>");
  15. document.write("body {");
  16. document.write(' background:url("' + banner[random] + '") no-repeat center top;');
  17. document.write(" }");
  18. document.write("</style>");
  19. </script>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.