(reprise du message précédent)
Bon ben voila un exemple qui marche sous IE et FF [et surement d'autres
]
Modifié par afbilou (18 Jul 2005 - 07:21)
Bon ben voila un exemple qui marche sous IE et FF [et surement d'autres

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<style type="text/css">
a.pouet {
font-size: 2em;
}
a.external {
background-color: red;
}
</style>
<script type="text/javascript">
window.onload = function() {
ExternUrl();
}
function ExternUrl()
{
var url;
var e = document.getElementsByTagName( 'a' );
for (var k=0 ; k<e.length ; k++)
{
url = e[k].href;
if (!(url.match(/^http:.*monsite\.fr/i) || url.substr(0,4)!='http'))
{
e[k].setAttribute('class' , e[k].getAttribute('class') + ' external');
e[k].setAttribute('className' , e[k].getAttribute('className') + ' external');
}
}
}
</script>
</head>
<body>
<p>
Un lien <a href="truc/super.html">interne</a>
<br />
Un lien <a class="pouet" href="http://oulala.ouke.je.vais.comme.ca">externe</a>
<br />
Un lien <a href="http://oulala.ouke.je.vais.encore.comme.ca">externe</a>
</p>
</body>
</html>
Modifié par afbilou (18 Jul 2005 - 07:21)