thebeebs | Getting strict on External links
thebeebs
Zeroing the desk - Ignore the design
 
 

Getting strict on External links

by thebeebs 15. November 2009 08:22

jquery 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');
});

Tags:

Comments (1) -

stratford on avon hotels
stratford on avon hotels United States
8/14/2011 10:03:39 AM #

Hey this is a great post. Could you keep me updated with any other info similar to this? If travelling to the UK why not stay at Stratford hotel and watch a Shakespear play

Comments are closed