var Nom = navigator.appName;
var version = navigator.appVersion;
if ( Nom == 'Microsoft Internet Explorer') {
if(version.match("MSIE 7.0")) {
alert(Nom+'\n'+version);
}
else if(version.match("MSIE 6.0")){
alert(Nom+'\n'+version);
}
}
else if ( Nom == 'Netscape') { // Netscape, firefox
alert(Nom+'\n'+version);
}
Ce code permet de détecter la version du navigateur :
IE 7, IE 6, et Firefox/Netscape.
Si vous avez besoin de faire deux css différents pour ie6 et ie7 utiliser ce bout de code en remplaçant le span par votre code
<?php
for ($i = 0; $i < sizeof($tab[0]); $i++) {
?>
<?php
//si c’est ie6
if(strstr($_SERVER['HTTP_USER_AGENT'], »MSIE 6.0″)!=FALSE){
?><span style= »position:relative;top:2px; »><a href= »contenu.php?id=<?=$tab[0][$i]['IdArticle']?> » mce_href= »contenu.php?id=<?=$tab[0][$i]['IdArticle']?> » class= »sousMenu »><?=$tab[0][$i]['LibelleArticle']?></a></span><?
}
//si c’est un autre navigateur
else{?>
<span style= »position:relative;top:-12px; »><a href= »contenu.php?id=<?=$tab[0][$i]['IdArticle']?> » mce_href= »contenu.php?id=<?=$tab[0][$i]['IdArticle']?> » class= »sousMenu »><?=$tab[0][$i]['LibelleArticle']?></a></span><?
}?>
Avec ce code :
strstr($_SERVER['HTTP_USER_AGENT'], »MSIE 6.0″)!=FALSE
on vérifie si la réponse du ‘HTTP_USER_AGENT’ contient bien ‘MSIE6.0′, c’est à dire qu’on détecte que c’est un IE6