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
☛ 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!
0 comments: