External link icons
-
Hi,
I wanted to add external link icons to my blog entries but I didn’t like the existing solutions, e.g. using CSS3 because they won’t work with most browsers.
So and friend of mine (thx Aaron) and I threw together a javascript function to attach an additional CSS class (‘e’) to external links. Here is the code:function stylizeLinks() {
aL = document.getElementsByTagName(‘a’);
for (i=0;i
if ((aL[i].hostname != location.hostname) &&
(aL[i].href.substring(0,10) != ‘javascript’) && (aL[i].href.substring(0,6) != ‘mailto’))
aL[i].className += ‘ e’;
}Include that in your index.php header and call the function in your BODY-tag with ‘onload’.
I tried the code with Opera and Firefox and IE. Sometimes IE gets a bit confused and hides the image for a second but overall it looks good.
I have it running @ my blog. Tell me what you think…
- The topic ‘External link icons’ is closed to new replies.