Steps to Open all External Links in New Tab :
- 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');
}
}
);
$("a[href^='https://']").each(
function(){
if(this.href.indexOf(location.hostname) == -1) {
$(this).attr('target', '_blank');
}
}
);
});
</script>
Thankyou!
http://www.technotraps.com/
Please note that such scripts can sometimes yield unexpected results. If you do not have too many external links you can also set each individual one to open in a new tab via the link option available in your individual posts. This is actually what I have now done on this blog as I found that some internal links (specifically my featured posts and related posts also opened in new tabs using the above script when I didn't want them to). Before you know it you can have 6 tabs open which can be an annoyance.
0 comments:
Post a Comment