Open all external links in new window in blogger automatically

Many friends have a problem that they have alot of external links in their blog and they want to open all the external links in new window automatically because they are not willing to modify every single external link. Because if have too much external links then this is very much time consuming and become boring too to modify all the external links one by one.
So to bypass this problem we find a very well working script. With the help of this script we can automatically make all external links to open in a new window, We only need to do is to put that script in our blogger template. This script will automatically make all the external links to open in new window. So let's see how to add script in your bloggger template:
Steps to open all external links in new window in blogger automatically:
- Goto blogger >> template
- Backup your template
- Click Edit HTML
- Search for </head> tag
- just of </head> paste the following below 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>
Note : Do not add the red coloured code if you already have jQuery library source code installed on your blog.
- Now save your template
Now you successfully make all your external links to open in new window automatically. Goto your site and click on some external links to check that the script is working or not.
If you have any problem then must comment below. We try to solve your problem as early as possible. Stay blessed and remember us in your precious prayers. If you want to share your thoughts or suggestions with us then comment below in the comment box.
Open all external links in new window in blogger automatically
Reviewed by Maher Afrasiab
on
9:04:00 am
Rating:
Reviewed by Maher Afrasiab
on
9:04:00 am
Rating:
No comments: