by

Open all external links in a new tab

image_pdfimage_print

Open all external links in a new tab
Follow these easy steps to add this cool dynamic way of updating all external links.
Note: This method works for both blogger and wordpress blogs, irrespective of platforms.

  1. Go to Blogger > Template
  2. Backup your template
  3. Click “Edit HTML”
  4. Just above </head> paste the following script: 

<script src=’http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js’ 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>

PS: Please do not add the red code if you already have jQuery library source code installed on your blog.
     5. Save your template and you are all done!

image_pdfimage_print

1 Comment

Leave a Reply

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