Highlight external links with favicons

Many sites like to apply distinct styling to their external links to let users know they will leave the site if they click on them. Wikipedia is a good example of this, using a blue box-arrow icon applied as a background image to links with the "external" class.

A slight more colourful approach would be to use the target website's favicon. This not only makes for an arguably more visually appealing design, but in certain circumstances, allows users to quickly see to which domain a link will probably take them:

BeforeAfter
External links styled with an icon (left) and with the target site's favicon (right)

This can be achieved using a few lines of JavaScript and Google's favicon cache. Google use this technique on some of their sites and as such keeps a cache of favicons as PNGs accessible by passing the domain as a parameter to the following url:

http://s2.googleusercontent.com/s2/favicons?domain_url=[DOMAIN]

So for example:

<img src="http://s2.googleusercontent.com/s2/favicons?domain_url=http%3A//semplicewebsites.com" width="16" height="16" alt="Favicon" />

gives our favicon: Favicon. It also gives a nice fallback icon when a favicon isn't found: Favicon

The code

To being with we need our HTML...

<a href="http://www.google.com" class="external">Google</a>

... and some CSS rules...

a.external {
  padding-left: 18px;
  background: url('http://s2.googleusercontent.com/s2/favicons') left center no-repeat;
}

This also defines the fall-back icon for when JavaScript is disabled.

Then we add our JavaScript. For this I will assume that you are using a JavaScript framework that allows you to select an element with a CSS selector. In this example I am using jQuery:

$('a.external').each(function() {
  var host = $(this)[0].host.replace(':80', '');
  $(this)[0].style.backgroundImage =
    'url("http://s2.googleusercontent.com/s2/favicons?domain_url=' +
    escape('http://' + host) + '")';
});

This code is added to the bottom of the page, or a page load event. ":80" is added to the a.host value by IE6, so this is removed as it unnecessary for searching the Google cache.

If you don't have the ability to mark all your external links with a class you can change your css selector to find them automatically:

$('a[href^=http]').each(function() {
  ...
  ...
});

All scripts are Public Domain.

Comments

jouer au casino gratuitement 770
casino 770 jeux gratuit partouche http://casinoballurex.com/ - casino gratuits sans telechargement
casino montreal jeux gratuit

online doctor
viagra without doctor prescription judpharmacy
how to get viagra
[url=http://viagratyrif.com/#]viagra without doctor prescription judpharmacy[/url]
how to get viagra
viagra without doctor prescription
meds online without doctor prescription
[url=http://viagrawithoutdoctorjwqa.com/#]generic viagra without a doctor prescription[/url]
manatee county courthouse

cialis without doctor prescription
viagra without doctor prescription
levitra without a doctor prescription
viagra without a doctor prescription
non prescription viagra
100mg viagra without a doctor prescription
online doctor
viagra without doctor prescription
online prescriptions

non prescription viagra
viagra without prescription
over the counter viagra
100mg viagra without a doctor prescription
meds online without doctor prescription
generic viagra without a doctor prescription
best generic viagra websites
viagra without prescription
no prescription viagra

non prescription viagra
viagra without prescription
over the counter viagra
100mg viagra without a doctor prescription
meds online without doctor prescription
generic viagra without a doctor prescription
best generic viagra websites
viagra without prescription
no prescription viagra

R anr.ogtl.semplicewebsites.com.rca.uk interference equipment; [URL=http://center4family.com/cialis-without-prescription/ - cialis 20 mg lowest price[/URL - [URL=http://wyovacationrental.com/viagra-online-canada/ - viagra buy in canada[/URL - [URL=http://wyovacationrental.com/cialis-5mg/ - where to buy cialis online without script[/URL - [URL=http://center4family.com/canadian-pharmacy/ - online pharmacy[/URL - [URL=http://scoverage.org/cialis-pills/ - generic cialis lowest price[/URL - [URL=http://wyovacationrental.com/buy-levitra/ - price of levitra 20 mg[/URL - [URL=http://a1sewcraft.com/viagra-online-canada/ - buy viagra online[/URL - viagra for sale only; cialis cheep viagra cialis walmart pharmacy cialis 20mg cialis levitra online viagra patient appropriately position, http://center4family.com/cialis-without-prescription/#tadalafil-20mg-low... cialis 20 mg lowest price http://wyovacationrental.com/viagra-online-canada/#viagra-buy-in-canada viagra online canada http://wyovacationrental.com/cialis-5mg/#cialis-5mg cialis drug cialis http://center4family.com/canadian-pharmacy/#pharmacy-online pharmacy http://scoverage.org/cialis-pills/#cialis-generic cialis generic http://wyovacationrental.com/buy-levitra/#generic-levitra-20mg levitra 20 mg walmart http://a1sewcraft.com/viagra-online-canada/#took-viagra cheap viagra size proof gallbladder.

meds online without doctor prescription
viagra without a doctor prescription walmart
online doctor
generic viagra without subscription
viagra without prescription
100mg viagra without a doctor prescription
online prescription
viagra without a doctor prescription
over the counter viagra

casino en ligne france autorise
casino montreal jeux gratuit http://casinoballurex.com/ - casino gratuits sans telechargement
casino 770 jeux gratuit partouche

cialis without doctor prescription
viagra without doctor prescription
polk circuit judge dennis maloney
viagra without a doctor prescription
levitra without a doctor prescription
viagra without a doctor prescription
generic viagra without a doctor prescription
viagra without doctor prescription judpharmacy
viagra prescriptions over internet

cialis without doctor prescription
viagra without doctor prescription
polk circuit judge dennis maloney
viagra without a doctor prescription
levitra without a doctor prescription
viagra without a doctor prescription
generic viagra without a doctor prescription
viagra without doctor prescription judpharmacy
viagra prescriptions over internet

casino montreal jeux gratuit
casino 770 jeux gratuits dernieres machines http://casinoballurex.com/ - jeux casino gratuits machine sous
casino en ligne france autorise

casino en ligne
jeu de casino gratuit francais http://casinoballurex.com/ - jouer en ligne casino montreal
casino en ligne spin palace

online doctors that provide prescriptions
viagra without doctor prescription
viagra without doctor prescription
viagra without prescription
best generic viagra websites
100mg viagra without a doctor prescription
meds online without doctor prescription
viagra without prescription
viagra doctor prescription

400 machines a sous gratuites
jouer en ligne casino montreal http://casinoballurex.com/ - 400 machines a sous gratuites
jouer en ligne casino montreal

1000 jeux de casino dispo
jeux casino gratuits machine sous http://casinoballurex.com/ - jouer en ligne casino montreal
machine a sous gratuites avec bonus

viagra without doctor prescription
viagra without doctor prescription
sildenafil without a doctor's prescription
viagra without a doctor prescription walmart
calhoun county courthouse
viagra without a doctor prescription
non prescription viagra
100mg viagra without a doctor prescription
viagra without doctor prescription

calhoun county courthouse
viagra without doctor prescription
online prescriptions
generic viagra without subscription
levitra without a doctor prescription
viagra without doctor prescription
generic viagra without a doctor prescription
viagra without a doctor prescription walmart
viagra without prescription

over the counter viagra
viagra without a doctor prescription walmart
prescriptions online
100mg viagra without a doctor prescription
buy generic viagra - judpharmacy
generic viagra without a doctor prescription
cialis without doctor prescription
viagra without prescription
buy medication without an rx

levitra without a doctor prescription
viagra without prescription
online doctor
viagra without prescription
circuit judge dennis p. maloney
viagra without a doctor prescription walmart
over the counter viagra
generic viagra without a doctor prescription
sildenafil without a doctor's prescription

les casinos
jouer en ligne casino montreal http://casinoballurex.com/ - jouer au casino sur internet
casino en ligne spin palace

levitra without a doctor prescription
viagra without doctor prescription judpharmacy
viagra prescriptions over internet
viagra without a doctor prescription walmart
levitra without a doctor prescription
100mg viagra without a doctor prescription
online doctors that provide prescriptions
viagra without doctor prescription
online doctors prescriptions

casino montreal jeux gratuit
casino en ligne france autorise [url=http://casinoballurex.com/]jouer au casino gratuitement 770[/url]
casino gratuits sans telechargement

Здравствуйте!
Нашел интересные фотоподборки на этом сайте: http://limonos.ru :
красивые gif гифки с днем рождения женщине
стили дизайна http://limonos.ru/dizajn/
http://limonos.ru/5365-domik-mechty-vo-francuzskih-alpah.html Домик мечты во Французских Альпах
Ученые выяснили, кто был главным на планете 200 млн лет назад Ученые выяснили, кто был главным на планете 200 млн лет назад
http://limonos.ru/1226-10-samyh-bolshih-samoletov-v-mire.html

jeux de casino
casino demo gratuit machine sous http://casinoballurex.com/ - casino en ligne
casino sans telechargement gratuit 770

casino en ligne bonus sans depot immediat
les casinos http://casinoballurex.com/ - jeu de casino gratuit francais
casino

Some vbi.xamu.semplicewebsites.com.fcc.sz stenosing atrium [URL=http://oliveogrill.com/buy-lasix-online/ - lasix no prescription[/URL - [URL=http://livinlifepc.com/buy-dapoxetine/ - priligy dapoxetine[/URL - [URL=http://columbiainnastoria.com/cialis-5mg/ - cialis generic[/URL - [URL=http://buckeyejeeps.com/buy-prednisone/ - prednisone no prescription[/URL - [URL=http://scoverage.org/levitra-coupon/ - levitra[/URL - [URL=http://livinlifepc.com/buy-propecia-online/ - propecia[/URL - [URL=http://oliveogrill.com/cheap-levitra/ - bayer vardenafil[/URL - computerized protrude meeting buy lasix priligy cialis without prescription buy prednisone without a prescription real levitra 20mg pills finasteride hazzards waht does finasteride interact with levitra depletion; http://oliveogrill.com/buy-lasix-online/#lasix buy lasix online buy lasix online http://livinlifepc.com/buy-dapoxetine/#priligy-dapoxetine generic priligy dapoxetine http://columbiainnastoria.com/cialis-5mg/#cialis-generic cialis pills http://buckeyejeeps.com/buy-prednisone/#prednisone-without-a-prescription prednisone without a prescription prednisone tablets http://scoverage.org/levitra-coupon/#levitra vardenafil hcl tablets vente levitra http://livinlifepc.com/buy-propecia-online/#propecia propecia buy online http://oliveogrill.com/cheap-levitra/#buy-levitra-on-line levitra generic levitra generic staphylococcal to: venous.

Bias qmu.thau.semplicewebsites.com.lhl.vw hydrogen lid spongiosum [URL=http://oliveogrill.com/buy-lasix-online/ - lasix[/URL - lasix online [URL=http://livinlifepc.com/buy-dapoxetine/ - generic priligy dapoxetine[/URL - [URL=http://columbiainnastoria.com/cialis-5mg/ - cialis generic[/URL - [URL=http://buckeyejeeps.com/buy-prednisone/ - online prednisone with no prescription[/URL - prednisone 20 mg side effects [URL=http://scoverage.org/levitra-coupon/ - generic drug for levitra[/URL - [URL=http://livinlifepc.com/buy-propecia-online/ - propecia[/URL - [URL=http://oliveogrill.com/cheap-levitra/ - www.levitra.com[/URL - nasopharynx gnashing ribs buy lasix online priligy buy cialis prednisone 10mg levitra on line order propecia cheap levitra configurations, http://oliveogrill.com/buy-lasix-online/#lasix lasix without prescription http://livinlifepc.com/buy-dapoxetine/#priligy buy dapoxetine http://columbiainnastoria.com/cialis-5mg/#cialis-pills cialis generic http://buckeyejeeps.com/buy-prednisone/#buying-prednisone prednisone no prescription http://scoverage.org/levitra-coupon/#vardenafil will donate my levitra levitra on line http://livinlifepc.com/buy-propecia-online/#buy-propecia-online propecia http://oliveogrill.com/cheap-levitra/#cheap-levitra cheap levitra electric backache begin.

Bias qmu.thau.semplicewebsites.com.lhl.vw hydrogen lid spongiosum [URL=http://oliveogrill.com/buy-lasix-online/ - lasix[/URL - lasix online [URL=http://livinlifepc.com/buy-dapoxetine/ - generic priligy dapoxetine[/URL - [URL=http://columbiainnastoria.com/cialis-5mg/ - cialis generic[/URL - [URL=http://buckeyejeeps.com/buy-prednisone/ - online prednisone with no prescription[/URL - prednisone 20 mg side effects [URL=http://scoverage.org/levitra-coupon/ - generic drug for levitra[/URL - [URL=http://livinlifepc.com/buy-propecia-online/ - propecia[/URL - [URL=http://oliveogrill.com/cheap-levitra/ - www.levitra.com[/URL - nasopharynx gnashing ribs buy lasix online priligy buy cialis prednisone 10mg levitra on line order propecia cheap levitra configurations, http://oliveogrill.com/buy-lasix-online/#lasix lasix without prescription http://livinlifepc.com/buy-dapoxetine/#priligy buy dapoxetine http://columbiainnastoria.com/cialis-5mg/#cialis-pills cialis generic http://buckeyejeeps.com/buy-prednisone/#buying-prednisone prednisone no prescription http://scoverage.org/levitra-coupon/#vardenafil will donate my levitra levitra on line http://livinlifepc.com/buy-propecia-online/#buy-propecia-online propecia http://oliveogrill.com/cheap-levitra/#cheap-levitra cheap levitra electric backache begin.

casino en ligne
casino gratuits sans telechargement http://casinoballurex.com/ - jouer au casino sur internet
casino 770 jeux gratuits dernieres machines

casino
jouer au casino gratuitement 770 http://casinoballurex.com/ - jouer au casino partouche
casino gratuits sans telechargement

casino
jouer au casino gratuitement 770 http://casinoballurex.com/ - jouer au casino partouche
casino gratuits sans telechargement

casino
jouer au casino gratuitement 770 http://casinoballurex.com/ - jouer au casino partouche
casino gratuits sans telechargement

casino
jouer au casino gratuitement 770 http://casinoballurex.com/ - jouer au casino partouche
casino gratuits sans telechargement

casino
jouer au casino gratuitement 770 http://casinoballurex.com/ - jouer au casino partouche
casino gratuits sans telechargement

casino
jouer au casino gratuitement 770 http://casinoballurex.com/ - jouer au casino partouche
casino gratuits sans telechargement

casino
jouer au casino gratuitement 770 http://casinoballurex.com/ - jouer au casino partouche
casino gratuits sans telechargement

casino
jouer au casino gratuitement 770 http://casinoballurex.com/ - jouer au casino partouche
casino gratuits sans telechargement

casino sans telechargement gratuit 770
jouer en ligne casino montreal http://casinoballurex.com/ - jeux casino 777 gratuitement
jeux casino gratuits machine sous

casino demo gratuit machine sous
jouer au casino gratuitement 770 http://casinoballurex.com/ - casino gratuits sans telechargement
machine a sous gratuites avec bonus

jeux de casino gratuit 770
jouer au casino gratuitement 770 http://casinoballurex.com/ - casino gratuits sans telechargement
casino kahnawake machine a sous

Pages

Add new comment