Open all hyperlinks in a new tab

JQuery is #1 the solution for most of the problems that we encounter when we make a website. Recently I also stuck with a question, how to open all external links in a new window/tab without altering the content posted by the client/website owner .

 

The solution is simple , just add a jquery code at the end of the page and it is done! This is very useful if it is a CMS website.

 

[javascript]

$(document).ready(function(){
$("body a[href^=’http://’]").attr("target","_blank");
});

[/javascript]

 

Demo can be found  HERE

Leave a Reply

Your email address will not be published. Required fields are marked *