April 3, 2011 By April M
This code below will allow all your links and buttons to open in a new window without having to do any extra work (meaning – WITHOUT adding the target=”_blank” to each and every link). Yay!! The code below will scan your blog for external pages and add the target=”_blank” to each and every one of them.
Before you begin please be sure to save a copy of your current HTML Code to your computer first.
Step 1: Log into Blogger then click on “Design” > “Edit HTML”
Step 2: Press Ctrl+F and find this code . Right before that code copy and paste the following:
//
jQuery(‘a’).each(function() {
// Let’s make external links open in a new window.
var href = jQuery(this).attr(‘href’);
if (typeof href != ‘undefined’ && href != “” && (href.indexOf(‘http://’) != -1 || href.indexOf(‘https://’) != -1) && href.indexOf(window.location.hostname) == -1) {
jQuery(this).attr(“target”, “_blank”);
}
});
//]]>
Step 3: Click “Save Template”
Let me know if it works for you.