您可能希望将页面上的所有外部链接都显示给用户。 可能是您要使用链接到的外部站点的favicon.ico(如果可用)。
这是您的操作方式!
jQuery('a[href^="http://"]').filter(function(){
return this.hostname && this.hostname !== location.hostname;
}).each(function() {
var link = jQuery(this);
//assuming it's in the root directory
var faviconURL =
link.attr('href').replace(/^(http://[^/]+).*$/, '$1')+'/favicon.ico';
var faviconIMG = jQuery('')['appendTo'](link);
var extImg = new Image();
extImg.src = faviconURL;
if (extImg.complete)
faviconIMG.attr('src', faviconURL);
else
extImg.onload = function() { faviconIMG.attr('src', faviconURL); };
});
From: https://www.sitepoint.com/jquery-add-site-favicon-external-links/