Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get website's favicon with JS

I am wondering if it is possible to get a website's favicon by an URL with JavaScript.

For example I have an URL http://www.bbc.co.uk/ and I would like to get path to favicon described in <link rel="icon" .../> meta tag - http://www.bbc.co.uk/favicon.ico.

I have many URLs so that should not load every page and search for link tag I think.

Any ideas ?

like image 752
hsz Avatar asked Jan 13 '10 15:01

hsz


People also ask

How do I get a favicon from a website?

Right-click on the website and click the "View page info" option from the list. It will open up a dialog and click on the "Media" tab. In that tab you will see all the images including favicon.

How do I create a dynamic favicon?

To change favicons, just go favicon. change("ICON URL") using the above. (credits to http://softwareas.com/dynamic-favicons for the code I based this on.)

What is favicon in Javascript?

A favicon is a small image displayed next to the page title in the browser tab.

How do I get a favicon from a website chrome?

You can click Ctrl + U to view source and look for the favicon in the code ( <link rel="shortcut icon" ).


1 Answers

Here are 2 working options, I tested over 100 urls and got different results which each option. Please note, this solution is not JS, but JS may not be necessary.

<!-- Free -->  <img height="16" width="16" src='http://www.google.com/s2/favicons?domain=www.edocuments.co.uk' /> <!-- Paid --> <img height="16" width="16" src='http://grabicon.com/edocuments.co.uk' /> 
like image 100
Blowsie Avatar answered Oct 19 '22 13:10

Blowsie