Ver Mensaje Individual
  #3 (permalink)  
Antiguo 19/01/2007, 08:20
Avatar de Calítoe.:.
Calítoe.:.
 
Fecha de Ingreso: octubre-2006
Ubicación: Pontevedra (Galicia, España)
Mensajes: 158
Antigüedad: 17 años, 6 meses
Puntos: 10
Re: Wordpress: busco plugin para abrir links externos en otra ventana

Veo que lo has solucionado, pero te comento que con WP se pueden hacer un par de apaños con los "rel" de los enlaces desde el panel de control (si te interesa, te lo comento).

De todos modos mi solución para todos los sitios que manejo es poner rel="external" dentro de la etiqueta <a> (es que a veces no quiero que el enlace se abra en otra ventana, así que entonces no pongo nada). Para que funcione, enlazo un javascript en la cabecera de las páginas así:

Código HTML:
<script type="text/javascript" src="external.js"></script> 
Y el contenido del external.js es este:

Código:
setExternalLinks=function() {
if ( !document.getElementsByTagName ) {
return null;
}

var anchors = document.getElementsByTagName( "a" );
for ( var i = 0; i < anchors.length; i++ ) {
var anchor = anchors[i];
if ( anchor.getAttribute( "href" ) && anchor.getAttribute( "rel" ) == "external" ) {
anchor.setAttribute( "target", "_blank" );
}
}
}

nav_hover=function() {
if (document.all&&document.getElementById) {
if (document.getElementById("hmenuroot")) {
navRoot = document.getElementById("hmenuroot");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
if (document.getElementById("navlinks")) {
navRoot = document.getElementById("navlinks");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="DIV") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
}

if (document.all&&window.attachEvent) { // IE-Win
window.attachEvent("onload", nav_hover);
window.attachEvent("onload", setExternalLinks);
} else if (window.addEventListener) { // Others
window.addEventListener("load",setExternalLinks,false);
}

/* } else if (document.all&&document.getElementById) { */
/* window.onload=nav_hover; // ie5-mac case */
/* } */
/* } else if (document.all&&document.getElementById) { */
/* window.onload=nav_hover; // ie5-mac case */
/* } */