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

Attraction, Status, and the Curious Pattern Behind Some Marriages

There has been a lot of discussion lately about celebrity divorces. As someone who closely observes human behavior, I have been thinking about a possible pattern behind some relationships. Before explaining my thought, I should mention something about my own background. From childhood, I was never particularly drawn to the idea of physical beauty. In fact, I even had a somewhat negative view of it. This may have come from the value systems around me while growing up. I also remember a religious gathering where someone said that a woman's beauty reflects her inner mind. Even at that time, I instinctively rejected that idea. Over the years, however, I have started noticing certain patterns in couples. When couples walk closely together, sit near each other, and interact affectionately in public, there often seems to be an interesting dynamic. In many such cases, the woman appears more attractive than the man. Sometimes she also seems more powerful in...

Idea crazy and free advices on rise

Just for the sake of record, I have noted that "idea crazy" people who think theirs is novel and should be kept secret are on rise. Though I agree to some extent that the ideas be kept secret to get pioneership [sic] credit, I wonder, why they can't compare Coca cola and Pepsi. People giving "free advices" on "ideas" are also on rise.