/ Published in: jQuery
                    
                                        
From Liviu HolhoÅŸ - Blog
http://blog.liviuholhos.com/javascript/add-a-favicon-near-external-links-with-jquery
                http://blog.liviuholhos.com/javascript/add-a-favicon-near-external-links-with-jquery
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
jQuery('a[href^="http://"]').filter(function(){
return this.hostname && this.hostname !== location.hostname;
}).each(function() {
var link = jQuery(this);
var faviconURL =
link.attr('href').replace(/^(http:\/\/[^\/]+).*$/, '$1')+'/favicon.ico';
var faviconIMG = jQuery('<img src="favicon.png" alt="" />')['appendTo'](link);
var extImg = new Image();
extImg.src = faviconURL;
if (extImg.complete)
faviconIMG.attr('src', faviconURL);
else
extImg.onload = function() { faviconIMG.attr('src', faviconURL); };
});
URL: http://blog.liviuholhos.com/javascript/add-a-favicon-near-external-links-with-jquery
Comments
 Subscribe to comments
                    Subscribe to comments
                
                