Please enter your login details.

Displaying a favicon in HTML
(Monday 15th of October 2012 08:50:17 AM) (5166 views) (0 comments)
Reliably displaying favicons in HTML (and a little javascript) is really easy! Most websites simply store the their icon at the root of the website. So for example looks like this "". However for IPlayer the BBC store the favicon in the page directory. So that's and looks like this "".

So for sites like IPlayer we need to fall-back to the site root icon but only after trying the page directory first. Unfortunately the HTML <img> tag doesn't have any way of doing this without a little help from javascript. Here's how..

<img src="" onerror='this.onerror = null; this.src=""'> </img>

Easy, right?!

Please login to post comments.

Copyright © 2011 Christopher James Plant Page generated in 0.004 seconds using 5 database queries. Style & Emoticons: "Default" by Kaloth
Icons: "Small Icons" by WendellVerli