BLOG BEGINNER GUIDE

Automatically Open all External Links in a New Window in Blogger

by Unknown  |  in Blogging Tips & Tricks at  10:35 AM

In this post I will show you How to Automatically Open all External Links in a New Window in Blogger. Thus preventing your blog readers from leaving your blog and also helps in increasing your overall pageviews and bounce rate. We thought we shall also share the script with all of you.

Automatically Open all External Links in a New Window in Blogger


Automatically Open all External Links in a New Window in Blogger


☛ Go to Blogger > Template
☛ Click "Edit HTML"
☛ Just above </head> paste the following script:
[ Note : To copy below code just move your mouse on code area. You will see
On right side. Click <> to copy code. ]

<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>

☛ Please do not add <script src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js' type='text/javascript'></script> if you already have jQuery library source code installed on your blog.

☛ Save your template and you are all done!

Subscribe to Get Updates in Your MailBox!

Follow us on!

Rasel MahmudThis Post Was Written By Rasel Mahmud
Hi I am Rasel Mahmud, Author of this Blog. I am 25 years old and originally from Natore, Bangladesh. I love blogging and helping people. I write about Blogging, Social Media, SEO, Adsense, WordPress, Technology Review on this blog.
Follow Me On : | | Facebook | Twitter

0 comments:

Proudly Powered by Blogger.