Once upon a browser

Once upon a browser is a bookmarklet you can use to randomly rotate elements on the page.

Drag this link to your bookmarks bar:

Once upon a browser

This is based on the idea presented in the article Spinning the Web by Eric Meyer.

Here is Eric’s Flickr set, and here’s mine, embedded here in the page as well.

Code

(function () {
    Array.prototype.slice.call(document.getElementsByTagName('body')[0].getElementsByTagName('*')).forEach(function (el) {
        ['-webkit-transform', '-ms-transform', 'transform', 'MozTransform'].forEach(function (s) {
            if (el.style[s] != undefined) {
                el.style[s] = 'rotate(' + (Math.random() * 120) + 'deg)'
            }
        });
        ['-webkit-transition', 'transition', 'MozTransition'].forEach(function (s) {
            if (el.style[s] != undefined) {
                el.style[s] = 'all 1.5s ease-in-out'
            }
        });
    });
})()

If you would like to play around, here’s the URL to source code on GitHub.

Browsers

Tested and works in following browsers:

  • Google Chrome 19
  • Mozilla Firefox 12
  • Internet Explorer 9
  • Opera 12
  • Safari 5.1.7
  • Android 2.3.4 stock browser

Gallery

Have fun!


Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.