External Links in New Windows
2009-11-10 10:58:09 | 0 Comment
If you are using markdown with your blog or sick and tired of adding target="_blank" to your links while creating a new post and if you just simply write the link and skip, here is my solution for you:
$(document).ready(function () {
$('a:not([href^="http://www.mengu.net/"])').each(function(i) {
if (!$(this).attr('target'))
{
$(this).attr('target', '_blank');
}
});
});
If you add this 8 lines of code to your header, then all the external links on your blog or web site will be opened in new window. Do not forget to include jquery too.
If you want to know why I really needed it, you can see here.

Comments
Leave a Response