Please enter your login details.

Displaying a favicon in HTML
(Monday 15th of October 2012 08:50:17 AM) (6592 views) (1 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?!

28/04/22 00:10:24
Hi there!

Please login to post comments.

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