This is a really cool hack which will make all the external links to open in new tab or new window. It is based on JavaScript and is really easy to implement.
Why use it?
- Prevent typing “target=’_blank’” again and again for external links
- Lets users to see the outside links while staying on your site.
- If there are some links which don’t have “target=’_blank’” in there <a> tag, then this script will also open them on new page.
Installation
Find the </head> tag in your blogger template code by using ctrl+F and place the below code above it.Also replace www.yourblog.blogspot.com and yourblog.blogspot.com with your blog’s address.
<script language='javascript'>Save your template and its done.
//<![CDATA[
var dominio = "www.yourblog.blogspot.com";
var dominio1 = "yourblog.blogspot.com";
var script = "javascript:void(0);";
var imagenesblogger0 = "bp0.blogger.com";
var imagenesblogger1 = "bp1.blogger.com";
var imagenesblogger2 = "bp2.blogger.com";
var imagenesblogger3 = "bp3.blogger.com";
var blogger1 = "www.blogger.com";
var blogger2 = "www2.blogger.com";
var publicidad = "pagead2.googlesyndication.com";
function LinksExternos() {
var Externo;
if (document.getElementsByTagName('a')) {
for (var i = 0; (Externo = document.getElementsByTagName('a')[i]); i++) {
if (
Externo.href.indexOf(dominio) == -1 &&
Externo.href.indexOf(dominio1) == -1 &&
Externo.href.indexOf(script) == -1 &&
Externo.href.indexOf(imagenesblogger0) == -1 &&
Externo.href.indexOf(imagenesblogger1) == -1 &&
Externo.href.indexOf(imagenesblogger2) == -1 &&
Externo.href.indexOf(imagenesblogger3) == -1 &&
Externo.href.indexOf(publicidad) == -1 &&
Externo.href.indexOf(blogger1) == -1 &&
Externo.href.indexOf(blogger2) == -1
)
{
Externo.setAttribute('target', '_blank');
//Externo.setAttribute('class', 'linkexterno');
}
}
}
}
window.onload = function() {
LinksExternos();
}
//]]>
</script>
thnx to bloggerz bible
No Response to "Open all external links on new page"
Post a Comment