Yabo-concept's Blog

Eviter les erreurs de validation W3C à cause du target="_blank"

Wednesday 27 January

Problème fréquent avec le doctype xhtml strict, l'attribut "target" empèche la validation W3C

jQuery permet de résoudre très simplement le problème

Avec l'attribut rel='external'

$(document).ready(function(){
	$("a[rel='external']").click(function(){
	  this.target = "_blank";
	});
}); 

Ou au choix, avec une classe class='external'

$(document).ready(function(){
	$("a.external").click(function(){
	  this.target = "_blank";
	});
}); 

Commentaires

Add A Comment

Add A Comment

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)
Notify me of any further comments to this thread