Open external links in a new window

Is it possible to make some sort of change or add a plugin that allows me to make every ‘external’ link open in a new window?

Just an example: if my blog was called http//timmy.com/ and I wanted to link to http//tom.com/, it would open a new window instead of the same window,
but I wanted to link from http//timmy.com/ to http//timmy.com/somewhere/ in the same window.

So I want all external link from my website to another in a new window/tab,
but I want every internal link, from my website to somewhere else on my website, to be in the same window/tab.

Is this possible?

4 Answers
4

Yup can be done with javascript.

var $j = jQuery.noConflict();

$j(document).ready(function() { //external attribute
    $j("a:not([@href*=http://YOURSITE.com/])").not("[href^=#]")
    .addClass("external")
    .attr({ target: "_blank" });
});

Leave a Comment