Live MeccaLive Blogger Tricks

Monday, 31 March 2014

How to make all External link open in new tab in blogger

Automatically make your all External  links in your blogger blog open in new Tab, you will be able to this by following this simple Tricks,tips and tutoeials . Default system is it open open all links in it's existing tab, or you need to add target="_blank" inside each hyperlink, or you can have use blogger post setting to add target="_blank" automatically. This is the easiest way to make link open in new tab in blogger or wordpress.

tips o make all link open in new tab in blogger
But what if you have published a lot of posts before, will you edit them and make all the links open in a new tab, NO. you can do this simply by adding some code. This is neccesary beacause, whenever you place any external links in your blog, If your visitor's hits the link they will be redirected to their blog in your existing page, and you loose your visitor.So it's quite important.

This will work on both blogger and wordpress blog in sha Allah.

  • First go to your Blogger Dashboard > Template.
Note : Before making any changes to your blogger template, BACKUP YOUR TEMPLATE.

  • Then click on Edit HTML and search for </head> and place the below codes just ABOVE/BEFORE </head> .

<script src='' type='text/javascript'></script><script type='text/javascript'>$(document).ready(function() {   $("a[href^='http://']").each(     function(){      if(this.href.indexOf(location.hostname) == -1)        $(this).attr('target', '_blank');       }     }   );$("a[href^='https://']").each( function(){ if(this.href.indexOf(location.hostname) == -1)$(this).attr('target', '_blank'); );  });</script>

Note : Remove the Red highlighted code if you have already jquery added before. 

  • Now save your template and see it will work in sha Allah.
I have Described the tutorial above. If you still face any problem, let me know. Comment below.

Courtesy : Mybloggertricks

Posted by:
has written 0 awesome articles for MyBloggerLab.

No comments:

Post a Comment