Open All External Links into New Tab in Blogger
Yesterday, I was posted a trick on how to add nofollow attribute to all external links automatically in blogger and today I bring another useful and helpful trick for all my blogger brothers and sisters. In this post I will show you that how can we open all external links into new tab. This can be done by adding simple jQuery code into template. Opening external links into new tab help to reduce your blog bounce rate and also you will not lose your valuable visitors. Now you have understood the benefits of opening external links into new tab so let's begin the tutorial.
Open External Links into New Tab
- Go to your blogger dashboard >> Edit HTML >> Tick Expand Widget Template Box
- Press Ctrl+F and find the below code.
- Now paste the below code above/before it.
- Save the template.
- Done!
</head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("a[href*='http://']:not([href*='"+location.hostname+"']),[href*='https://']:not([href*='"+location.hostname+"'])").attr("target","_blank").attr("title","Opens new window").addClass("external");
});
</script>
Note: Remove red line from code if you have already any jQuery.js file in your template.
0 commentaires:
Enregistrer un commentaire