Follow @josdirksen Tweet to @josdirksen Tweet

Random background from Colourlovers

This page uses the API from the COLOURlovers website to set a random background based on the top patterns. This is done by taking the following simple steps:

All you have to do this is (for more info see this article on

// We retrieve a set of the 50 top backgrounds
          function(data) {

  // we randomly select one of the elements
  var element = data[Math.floor(Math.random()*50)];

  // we update the body background with the url
    "background-image": "url("+ element.imageUrl +")"