I have written a function that returns the favicon by splitting the document's <head>
<link>
tags
rel="icon"
rel="shortcut icon"
function geticon(site,cb){
if(site.indexOf('http')==-1){site='http://'+site;}
$.get("https://mysite.me/middleman.php",{"site":site})
.always(function(d){
if(!d){cb('https://mysite.me/R/link.png',false);}
else{
d=d.split('<link ');
var ico='https://mysite.me/R/link.png';
for(var i=0;i<d.length;i+=1){
d[i]=d[i].split('>')[0];
if(d[i].indexOf('rel="icon"')!==-1||d[i].indexOf('rel="shortcut icon"')!==-1){
ico=(d[i].split('href="')[1]).split('"')[0];
break;
}}
site=(site.split('//')[1]).split('/')[0];
if(ico.indexOf(site)==-1&&ico.indexOf('http')!=0&&ico.indexOf('//')!=0){
if(ico[0]=='/'){ico=site+ico;}
else{ico=site+'/'+ico;}
}
if(ico.indexOf('http')==-1){
if(ico.indexOf('//')==0){ico='http:'+ico;}
else{ico='http://'+ico;}
}
if(!ico){cb('https://mysite.me/R/link.png',false);}
else{
getimg(ico,function(b,bool){cb(b,bool);});//returns base64 string
}}});}
but it fails to work with this url:
http://www.ipwatchdog.com/2012/09/07/uspto-issues-worlds-first-invisibility-cloak-patent/id=27841/
I have looked at the source code for the url but cannot identify the favicon in the code, yet the browser tab does have an image of a dog with a magnifying glass!
what am I missing? how many ways of declaring a favicon are there?
The favicon is located at http://www.ipwatchdog.com/favicon.ico following method 2 in the W3C's How to Add a Favicon to your Site which lists two methods of including a favicon on a website: