Try out random colors quickly through bookmarklets

In-page Demo: Click here

Color combination used in a web page is one of the most important ingredient of a good UI. If you get confused, like me, about which color / background-color to use, what can be better than trying out a bunch of random colors.

JavaScript Bookmarklet comes to rescue

Paste the following script in your address bar and press enter (or click Go)

javascript:(function(){var color=’#'+Math.floor(Math.random()*16777215).toString(16);document.body.style.backgroundColor=color;var newDiv=document.createElement(‘div’);newDiv.innerHTML+=color+’;';document.body.appendChild(newDiv);})();

The indented version of the JavaScript code:
(function(){
var color = ‘#’ + Math.floor(Math.random()*16777215).toString(16);
document.body.style.backgroundColor = color;

var newDiv = document.createElement(‘div’);
newDiv.innerHTML += color + ‘;’;
document.body.appendChild(newDiv);
})();

And yeah, once you like a color code, you can check its hex value at the bottom of the page (appended as a div at the bottom).

What got me interested into bookmarklets ? jQuerify !!!!

jQuery being the most popular and easy to use JavaScript library seems to be the best to play your page with. But if you wish to experiment with other websites using your JavaScript debugger console, but miss jQuery, look no further than http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet

This was the thing which really got me interested into the ease and flexibility that we get through JavaScript bookmarklets. Now, I could inspect/play-with any of the pages just by click on the bookmarklet before heading to my favorite JavaScript debugger, Firebug.