Posted By

thewickedchemist on 05/28/12


Tagged

jquery favicon CSS-Tricks


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

BrockSamsom


Show Favicon for external Link with jQuery


 / Published in: jQuery
 

Source: http://css-tricks.com/favicons-next-to-external-links/

  1. function getDomain(url) {
  2. return url.match(/:\/\/(.[^/]+)/)[1];
  3. }
  4.  
  5. $("a[href^='http']").each(function() {
  6. $(this).css({
  7. background: "url(http://favicon.yandex.net/favicon/" + getDomain(this.href) +
  8. ") left center no-repeat",
  9. "padding-left": "20px"
  10. });
  11. });

Report this snippet  

You need to login to post a comment.