Skip to content

Instantly share code, notes, and snippets.

@collectiveidea
Created May 1, 2009 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save collectiveidea/104791 to your computer and use it in GitHub Desktop.
Save collectiveidea/104791 to your computer and use it in GitHub Desktop.
display favicons next to links
// Requires prototype.js
// assumes you have some container with class .favicon with a bunch of links inside
// As seen on http://ideafoundry.info/embassy
// Documentation at http://daniel.collectiveidea.com/blog/2009/5/1/fun-with-favicons
function loadFavicons() {
$$('.favicon a').each(function(link){
link.setStyle({
background: 'url('+link.href+'favicon.ico) no-repeat 0 0',
paddingLeft: '24px'
});
link.setStyle("background-size: 16px; -webkit-background-size: 16px; -khtml-background-size: 16px;");
});
}
Event.observe(window, "dom:loaded", loadFavicons)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment