External Links

I like to have all external links open in a new window. However, the traditional method of

target=_blank

is not XHTML compliant. So another option is to use JavaScript’s window.open function.

Open external links in a new window, is a plugin that sorts this in WordPress. Any link starting http will open in a new window unless it matches the ignore options. Unfortunately this doesn’t seem to work in IE, so some extra work required. I would also like a default hover text such as ‘opens in new window’.

I also wanted to some means of showing which links are external ones. I found a nice css solution on the electric toolbox.

First apply the image to any anchor starting with ‘http’ (this allows for both http and https links, although it might be better to define separate images for each):

a[href^="http"] {
background: url(images/external.png) center right no-repeat;
padding-right: 13px;
}

Then make sure it ignores any absolute links for your own site:

a[href^="http://thehazels"]  {
background: none;
padding-right: 0;
}

I’ve used the icon available from Wikipedia and then coloured it in Gimp.

Scroll to Top