Skip to main content

jQuery.favicon - jQuery plugin for adding favicons next to the links

It's easy to add little favicons next to all or external links using CSS's background properties:



a[href ^="http://jquery.com"] {
background: url(http://jquery.com/favicon.ico) center right no-repeat;
padding-right: 16px;
}



But, to automate that for all links in a page, I wrote a nifty jQuery plugin--favicon (posted to jQuery group).

Side note



I don't know of anyway to parse the domain name of a link using JavaScript and so thought of using RFC compliant regexp and had to write a PHP helper to import regexp in JavaScript:



<?php
// Generate JavaScript regexp for matching URL for getting host part
// set user agent; otherwise getting 403
ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11');
echo str_replace(array(
"\n", // remove newline
'/', // escape / to \/
'?:' // remove--we really need mach
) , array(
'',
'\/',
''
) , file_get_contents('http://web.archive.org/web/20070302134659/foad.org/~abigail/Perl/url3.regex'));
?>

Comments

Anonymous said…
This comment has been removed by a blog administrator.

Popular posts from this blog

I'm Zend (PHP 5) Certified Engineer:-)

As of January 13, 2007, I'm ZCE/ Zend Certified Engineer (PHP 5)

Problems with CakePHP - follow-up

Some people have responded including the Datepicker fame Marc Grabanski . So, this follow-up... First of all, I was not ranting nor complaining; I've just blogged/documented my experience. The common problem most of the people pointed out are that it scales for addons.mozilla.com. Those who have accessed their source code can understand that they've done lot of things and also the site is not database-intensive. You should really create a real database-intensive website to understand what I mean. The other point that been pointed out is about open source and community. Lot of people may not be knowing that it's 2 people pushing it and don't want others to be credited . The generic model or dynamic model idea was originally been from grigri and Marcel . It's hard to be called as open source as only few and sycophants are driving it's direction (I'm not talking about svn access) So, here are my humble checklist before you start shouting at me Did you read a