External Links - thehazels External Links - thehazelsthehazels

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.

About Antonia Whitaker

An administrative, sales and marketing background has given me an understanding of what users want from their website. I do not confuse issues with technical jargon and I listen to what people want.

28. November 2013 by Antonia Whitaker
Categories: Wordpress | Tags: , | Leave a comment