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

Technology prediction for 2018

Bubbles of bitcoin, blockchain, machine learning, deep learning, artificial intelligence and more People usually appreciate me for my predictions on technologies. As I already noted our team will quickly hit the edge case for any use cases and that's supposed to be the reason for my better prediction rate. And so, here are my predictions… Bitcoin bubble When Bitcoin became talk of the town/industry, I informed my boss and colleagues that I find no real use case for this digital currency--except in underground markets like drugs, etc. In fiat currencies, there is at least a way to take legal route, in case, if you've transferred the money and not received the goods. But, in Bitcoin, this is not possible at all as it is not a legal currency. So, if there is no trust, the chances that other person can cheat you by not sending the goods and or not transferring bitcoins after receiving goods. My stand above vindicated by the article Ten years in, nobody has come up with a...

Did Evolution Undermine Motherhood—or Are We Simply Expecting Too Much from Mothers?

There’s an old saying that, 50 years ago, babies in South India would take 40 days to open their eyes—while today, they open them within minutes. Similarly, people used to believe that breastfeeding worked as a natural family planning method for up to five years about a century ago, but now, they say evolution has overridden that too. Along those lines, I wonder—has evolution diminished motherhood itself, or have we simply misunderstood and overburdened it? Although I don’t actively follow the news much these days, I still come across troubling stories—particularly from Tamil Nadu—where mothers have harmed or even killed their own children. In one viral video, a husband explains how his wife, addicted to Instagram reels, finds it too inconvenient to feed their child and calls him during work hours to do it instead. It raises a disturbing question: Are some Tamil mothers starting to see their own children as burdens—or is it the act of caregiving that feels burdensome? Perhaps bo...

Teachers' Kids: The Topper Syndrome

Tao Te Ching Fill your bowl to the brim and it will spill. Keep sharpening your knife and it will blunt. Chase after money and security and your heart will never unclench. Care about people's approval and you will be their prisoner. Do your work, then step back. The only path to serenity.