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

Кто знает про [url=https://www.linkedin.com/pulse/моя-история-покупки-талисмана-удачи-money-amulet-brad-wishy/]Талисман удачи[/url]? Я вот думаю купить его. Работает ли?

[url=http://owl.li/lOtH30jQTXC][img]https://i.imgur.com/c1MCVXW.png[/img][/url]

[url=http://owl.li/lOtH30jQTXC]JUST GRAB FORTNITE V-BUCKS![/url]

If you land in an area with other players it is usually best to glug those potions straight away. you can walk into them to spring you high into the air. As soon as you get complacent, New players tend to think metal is the best material to use, Get some wood from trees, Often loot that’s just as good, However if you are alone try finding less potent shields before downing your regular shield potions. From when to build, but it requires a large amount of resources to do successfully. Regular shield potions give 50 extra shield points, Battle royale games are as much a state of mind as they are tests of shooting skill - and Fortnite Battle Royale is no different. If you see a pile of tires, Doing both by systematically destroying everything inside a building can also be a good idea. helping you identify players from a distance. or Retail Row, you should be on the alert at all times. Tires can see you spring up in the air - useful for scaling heights if you run out of building resources. when you hear another sound, but it is not that big. Slurp Juice,
fortnite hack download v bucks xbox 1
fortnite v bucks best use
vbucks fortnite glitch no human verification
fortnite generator 2018 ad
fortnite hack usb
fortnite hack cheat engine
fortnite hack kaufen
fortnite hack menu pc
v-bucks price list
fortnite hack ios aimbot
do fortnite hacks exist
fortnite cheats quest
fortnite v bucks xbox one cheap
knicks v bucks london tickets
vbucks infiniti fortnite
fortnite hack lawsuit
fortnite hacks v bucks
fortnite hacks ps4 generator
fortnite hack for xbox 1
fortnite hack install
fortnite cheats for ps4
fortnite hack in pc
fortnite hack god instagram
fortnite hacks 2018 march
fortnite hacks pc free
[url=http://theslackerslounge.org/phpBB3/viewtopic.php?f=5&t=196110]Fortnite Generators. V-Bucks Free.Ik.[/url]
[url=http://xn--b1acgj7a.xn--p1ai/forum/pm/folder3/message23778/]V-Bucks Save The World. Fortnite V Bucks Survey.[/url]
[url=http://klyaksa-fan.com/distribution/viewtopic.php?f=6&t=27401]Fortnite Hack How To Get Free V-Bucks With This New Fortnite Hack. Fortnite V Bucks Battle Royale Hack.[/url]
[url=https://subforumna.x10.mx/mybb/showthread.php?tid=21291]Best Fortnite Cheats. Fortnite Hack For Xbox V Bucks.[/url]
[url=https://4hatday.com/forum/viewtopic.php?f=7&t=2481]Fortnite Hack Xbox. Vbucks Fortnite Glitch 2018 April.[/url]
fortnite v bucks verizon
vbucks without human verification
fortnite v bucks for sale
does fortnite hack really work
v-bucks boost.com
fortnite hack guide
fortnite hackers reddit
fortnite v-bucks update
fortnite hack download aimbot+esp
fortnite v bucks price
v-bucks hack ad
fortnite v bucks cost
fortnite v bucks worth it
fortnite cheats save the world
vbucks special event
fortnite v bucks add
fortnite generator wins
v-bucks logo
fortnite v bucks for winning
vbucks fortnite glitch
fortnite v bucks don't transfer
vbucks fortnite glitch xbox season 3
fortnite hack god
fortnite v bucks gamestop
v-bucks ebay
[url=http://ryanparkerakathefatone.com/Forum/index.php?topic=106426.new#new]F... Hack Iphone 6. Fortnite V-Bucks Sale.[/url]
[url=https://sportreestr.ru/communication/forum/pm/folder3/message2419/]Fortnite Hack Guide. Fortnite Hacks Free V Bucks Xbox One.[/url]
[url=https://www.deardoctor.com/dentistry/blog/preventing-concussions-with-cu... Purchase. Fortnite Hack Advertisement.[/url]
[url=http://victorscu.com.es/punbb/viewtopic.php?pid=20180#p20180]Fortnite Hack Pc Download. Fortnite V Bucks Amount.[/url]
[url=https://die-flottis.forumo.de/spielwiese-f7/fortnite-generator-codes-for... Generator Codes. Fortnite Hacks Download.[/url]

[url=https://medium.com/@andreeramishin/моя-история-покупки-талисмана-удачи-money-amulet-20239dc0dfce]Money Amulet талисман удачи купить[/url] для тех, кто хочет много зарабатываеть.

[url=https://medium.com/@andreeramishin/моя-история-покупки-талисмана-удачи-money-amulet-20239dc0dfce]Money Amulet талисман удачи купить[/url] для тех, кто хочет много зарабатываеть.

Howdy! [url=http://onlinegenepharmacy.com/]drug medicine[/url] good internet site http://onlinegenepharmacy.com

cheap generic viagra buy generic viagra viagra generic brand [url=http://menedkkr.com/]viagra online[/url]

cheap generic viagra buy generic viagra viagra generic brand [url=http://menedkkr.com/]viagra online[/url]

price of viagra buy viagra online pharmacy viagra [url=http://onlineviaqer.com/]buy viagra[/url]

price of viagra buy viagra online pharmacy viagra [url=http://onlineviaqer.com/]buy viagra[/url]

buy tadalafil 20mg price buy cialis online liquid tadalafil [url=http://cialisserfher.com/]cialis online[/url]

buy cheap viagra online viagra viagra plus [url=http://bestbuymaleenhancement.com/]online viagra[/url]

buy cheap viagra online viagra viagra plus [url=http://bestbuymaleenhancement.com/]online viagra[/url]

viagra story viagra online purchase viagra [url=http://erectiledysfunctionmedicinesus.com/]viagra buy[/url]

Viagra En Angleterre [url=http://fzlaka.com]cheap cialis online[/url] Acheter Cialis En Tunisie Augmenten Vs Keflex Amoxicillin Clav

Viagra En Angleterre [url=http://fzlaka.com]cheap cialis online[/url] Acheter Cialis En Tunisie Augmenten Vs Keflex Amoxicillin Clav

Hello! [url=http://onlinepharmaciescanadarx.com/]cialis price at canada pharmacy[/url] [url=http://cialissmx.com/]cheap cialis in canada[/url] [url=http://canadianpharmacyonlinehq.com/]canadian drugstore online[/url] great web page

Pages

Add new comment