Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/05/2008, 02:33
Avatar de ZiTAL
ZiTAL
 
Fecha de Ingreso: marzo-2004
Ubicación: Bermio (Bizkaia)
Mensajes: 1.545
Antigüedad: 20 años, 2 meses
Puntos: 62
Añadir funciones a eventos dinamicamente

Hola a todos, tengo un problemilla y es que me gustaria que algunos enlaces se abrieran en una ventana nueva, pero validando el xhtml, por lo tanto no vale el famoso target="_blank", por lo tanto quiero hacer un window.open:

Código:
function ext()
 {      
    var click='window.open(this.href);return false;';
    var links = document.getElementsByTagName("a"); 

    for (var i=0; i<links.length; i++)
     { 
        if (links[i].getAttribute("rel") && links[i].getAttribute("rel") == "external")
         { 
            links[i].setAttribute('onclick',click);
            //links[i].onclick=click;            
         }  
     } 
 }
window.onload=ext;
Pero el codigo no funciona, a alguien se le ocurre algo?
__________________
http://zital.no-ip.org
____________________

Euskerie ahuen eta bijotzan