It's easy to add little favicons next to all or external links using CSS's background properties:
But, to automate that for all links in a page, I wrote a nifty jQuery plugin--favicon (posted to jQuery group).
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:
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