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

Save American College, Madurai (Update 2011)

This article was written on Jan 16, 2011 and updated on Jan 26, 2011, Mar 16, 2011, Mar 21, 2011, Mar 28, 2011, Apr 10, 2011, and May 1, 2011 In 2008, I have written Save American College, Madurai that seemed to help many people including alumni to understand the situation, politics and chaos. At that time, I was favoring Principal's party as favoring Bishop's party could turn adverse as they're was already trying to replace non-permanent staffs; in fact, I have even donated a meager amount for the legal battle.[ Update : Corrected the sentence to convey the intended meaning. Thanks for those who pointed out] This time, people hit the same old article and asking the details. When I contacted, this time, nobody have clear reason for the chaos--except that it's a ego clash between Principal and Bishop party. Problems and reasons Till now, all bishops were being part of The American College, Madurai Governing Council. All/Most of the bishops played subtle r