<em>"This is not a holier-than-thou request to use web standards. This is not a hope for accessibility. This is a demand for my right as a web citizen to be able to click on hyperlinks without receiving javascript errors"</em>
Amen hermano
<em>"I hate you. I despise you. I wish for your sudden and excruciating death with every ounce of my being every single time I click one of your god-forsaken pretend hyperlinks. I swear to all the Gods in all the religions, that the next time this happens to me, somebody will pay. Oh yes. Somebody will be sorry"</em>
SAPOROSTI !!!
pd: de todas formas la solución que da no me acaba de molar ... prefiero lo que ponia Sergi o lo de SitePoint
A propósito, en youngpup.net encontré este article que también sta bien...el autor parece que está cabreado con más de uno, ejjejej
http://www.youngpup.net/2003/popups
Respecto a los "motivos" para hacerlo (articulo de SitePoint de Fede) .... sinceramente me parece cogérsela con papel de fumar ... estas son las cosas por las que la gente manda a freir espárragos al W3C
Además, añadir esas cosas por javascript no es más que engañar al validador, ya que el atributo se sigue usando, aunque escondido
Y no digo que no sea fácil, rápido o leches ... es que me niego a aceptarlo, por tocapelotas ... anda que no hay cosas que arreglar antes que esto (si es que esto hay que arreglarlo)
// Events methods by Scott Andrew (www.scottandrew.com):
addEvent : function(obj, evType, fn, useCapture){
if (obj.addEventListener){
obj.addEventListener(evType, fn, useCapture);
return true;
}
else if (obj.attachEvent){
var r = obj.attachEvent("on"+evType, fn);
return r;
}
else {
return false;
}
},
reTarget : function(){
var external = document.getElementsByTagName("a");
for (var k=0; k<external.length; k++){
if (external[k].href) {
var url = external[k].href;
if (url.indexOf(document.domain) == -1 && url.indexOf("javascript:") == -1)
{
var ExternalTxt = "(External link / Enlace externo)";
external[k].target = "_blank";
external[k].title += " " + ExternalTxt;
}
}
}
}
}
// extending Array, by Aaron Boodman (youngpup.net):
Array.prototype.indexOf = function(foo) {
for (var i = 0; i < this.length; i++)
if (foo == this[i]) return i;
return -1;
}
if (document.getElementsByTagName && !window.opera) {
// Op seems to crash with Extras.reTarget
Extras.addEvent(window, "load", Extras.reTarget, false);
}
//================================================\\
// end add-ons \\
//================================================\\</code>
yo empecé a usar el DOM para añadir el target (y una imagen al enlace) si el href era de fuera del dominio, pero parece que eso (exactamente la imagen, no el haber añadido el target) no le mola mucho al FireFox y lo descojona. Asi que ahora uso CSS (bueno ahora = mi nueva v3 que saldra pronto) para añadir una pequeña imagen que señala que la url es de fuera, y así la gente sabe que saldrá de mi dominio. Si alguien quiere o sabe, ya usará el botón derecho.
orange
<em>"This is not a holier-than-thou request to use web standards. This is not a hope for accessibility. This is a demand for my right as a web citizen to be able to click on hyperlinks without receiving javascript errors"</em>
Amen hermano
<em>"I hate you. I despise you. I wish for your sudden and excruciating death with every ounce of my being every single time I click one of your god-forsaken pretend hyperlinks. I swear to all the Gods in all the religions, that the next time this happens to me, somebody will pay. Oh yes. Somebody will be sorry"</em>
SAPOROSTI !!!
pd: de todas formas la solución que da no me acaba de molar ... prefiero lo que ponia Sergi o lo de SitePoint
meddle
estoy de acuerdo con vosotros. he dicho "puestos a usar js". yo simplemente paso del target.
y ese articulo lo he enlazado aqui por lo menos 4 veces. aaron is da king ;)
Usuario desconocido
Entiendo perfectly...no pasa res.
A propósito, en youngpup.net encontré este article que también sta bien...el autor parece que está cabreado con más de uno, ejjejej
http://www.youngpup.net/2003/popups
orange
Respecto a los "motivos" para hacerlo (articulo de SitePoint de Fede) .... sinceramente me parece cogérsela con papel de fumar ... estas son las cosas por las que la gente manda a freir espárragos al W3C
Además, añadir esas cosas por javascript no es más que engañar al validador, ya que el atributo se sigue usando, aunque escondido
Y no digo que no sea fácil, rápido o leches ... es que me niego a aceptarlo, por tocapelotas ... anda que no hay cosas que arreglar antes que esto (si es que esto hay que arreglarlo)
Cagontó
meddle
puestos a usar js, hombre, hagamoslo bien. no? algo como esto (mejor lo metes en un archivo js aparte, se inicializa solo):
<code>//================================================\\
// start add-ons \\
//================================================\\
var Extras = {
// Events methods by Scott Andrew (www.scottandrew.com):
addEvent : function(obj, evType, fn, useCapture){
if (obj.addEventListener){
obj.addEventListener(evType, fn, useCapture);
return true;
}
else if (obj.attachEvent){
var r = obj.attachEvent("on"+evType, fn);
return r;
}
else {
return false;
}
},
reTarget : function(){
var external = document.getElementsByTagName("a");
for (var k=0; k<external.length; k++){
if (external[k].href) {
var url = external[k].href;
if (url.indexOf(document.domain) == -1 && url.indexOf("javascript:") == -1)
{
var ExternalTxt = "(External link / Enlace externo)";
external[k].target = "_blank";
external[k].title += " " + ExternalTxt;
}
}
}
}
}
// extending Array, by Aaron Boodman (youngpup.net):
Array.prototype.indexOf = function(foo) {
for (var i = 0; i < this.length; i++)
if (foo == this[i]) return i;
return -1;
}
if (document.getElementsByTagName && !window.opera) {
// Op seems to crash with Extras.reTarget
Extras.addEvent(window, "load", Extras.reTarget, false);
}
//================================================\\
// end add-ons \\
//================================================\\</code>
Usuario desconocido
Mirá el mensaje número 8 de este topic:
http://www.webmasterworld.com/forum21/5529.htm
USING WINDOW.OPEN() , rel="external". maybe???
El mismo topic tiene un link a un artículo muy interesante en sitepoint.com, por cierto:
http://www.sitepoint.com/article/1041/1
meddle
yo empecé a usar el DOM para añadir el target (y una imagen al enlace) si el href era de fuera del dominio, pero parece que eso (exactamente la imagen, no el haber añadido el target) no le mola mucho al FireFox y lo descojona. Asi que ahora uso CSS (bueno ahora = mi nueva v3 que saldra pronto) para añadir una pequeña imagen que señala que la url es de fuera, y así la gente sabe que saldrá de mi dominio. Si alguien quiere o sabe, ya usará el botón derecho.
<code>#content a[href^="http"] {
padding-right: 10px;
background-image: url(external.gif);
background-position: right !important;
background-repeat: no-repeat;
}
</code>