by thebeebs
15. November 2009 08:22
If you want to have all links in your document that point to external sites open up in a new window then you’ll realise you can no longer use target=”_blank”… well that’s if you want to conform to XHTML strict. The Jquery Snippet below could solve your problem.
$.expr[':'].external = function(obj)
{
return !obj.href.match(/^mailto\:/) && (obj.hostname != location.hostname);
};
$(document).ready(function() {
$('a:external').attr('target', '_blank');
});
05f8dc50-3c33-451c-884b-eb67e9ec4895|0|.0
Tags: