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

Interview question #1

Since I have been asked to interview experienced PHP programmers, I was preparing few interview questions. I came to know, most of the people ask questions found in the Internet; most of them are like "What is the function used to connect MySQL DB in PHP". Personally, I don't like these types of questions; I'd thought the person must apply ideas what he was taught in colleges--finally I came out with one question: A product vendor has Quantity Vs. Price data like 1 -> Rs. 50 2 -> Rs. 95 3 -> Rs. 140 .... like upto 1 million data. He wants a system, which gives the price when the quantity is provided. For example, if you provide the quantity value as 2, then it should provide Rs. 95. How this system can be designed? As expected, all the people said about using database tables and quering on quantity. I have asked them to find out a system which doesn't use databases--provided the accuracy of the system may not be 100%--it may give at least 90% ac...

"A to Z of C" in the book Cimple (ISBN 0070260982)

I was just searching "A to Z of C" in Google Books and found that the book Cimple written by Sasant K Rout has used our code. The irony is that the book was published by Tata McGraw-Hill , who rejected us in final stage stating that it wants us to get endorsement from any IIT professor, which we couldn't. (For the sake of record... IIT Bangalore was linking & supporting "A to Z of C" for long time once it's published over the net; see old IIT page from web.archives.org ) It's just another incident to prove that success isn't a measurable unit; even failed attempts can be appreciated in any other forms.

CakePHP security issue - even in thechaw.com (written by core dev)

CakePHP security issue Recently I have stumbled upon thechaw.com --written by CakePHP core dev and developed in CakePHP. I just wanted to check if they have fixed the old security issue in CakePHP and found that the issue is still open. Proof of concept CakePHP memory error In another time, found a famous memory error even in bakery.cakephp.org Bottom line CakePHP is open source and so you can fix these issues by yourself