Monday, July 2, 2018

How To Make Blogger Posts With The External Links Open In New Tabs

How To Make Blogger Posts With The External Links Open In New Tabs
  • Follow These Steps:-

  • Go to your blogger dashboard
  • Select your blog >> Template
  • Backup your template before editing
  • Click on “Edit HTML”
  • Find </head> tag in HTML
  • Add the following piece of code just above the </head> tag
  • Save your Template, you are all done !!
Note : Please don’t add the red code if you already have jQuery library source code installed on your blog.

 <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');
 }
 }
 );

 }
 }
 );
 });
 </script>

Affected Links By Above jQuery Script:

Above jQuery script will check all hyperlinks inside your blog pages a
The script will only detect external hostnames and the moment it finds one,
it will insert into the html a target attribute that tells the browser to open the link in a new window.

Thanks!


.
Powered by Blogger.