How to open all link in new tab

How can i customize my theme in a way that all the links should open in new tab...





you need to add jQuery in the website(if its a wordpress blog, most probably it already is loaded)

then simply add this script in the footer/end of the body to do the job:


or you can omit the script tags altogether and put the code in some .js file instead
PS, this is just a quick patch, though you should have some sort of class for the anchor tags(links) so that only those links will be opened in new tab and doesn’t mess up with other link’s functionality

If you need to do this only for external urls, i.e. the urls that does not belong to your domain, then you can use this :

    if(jQuery(this).attr('href').indexOf(document.domain) == -1)