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](http://www.mengu.net/demo/post/web2py-sources).
Check my latest project compector.com where you can post references about your former employers and see what others have said about the future employers. Sign up now and post a reference and share it on twitter or facebook.


Comments
Leave a Response