OVH Cloud OVH Cloud

stylesheet dans firefox

1 réponse
Avatar
Michel Jeandon
je n'arrive pas à récupérer mes styles dans firefox

soit le code suivant:

<html>
<head>
<style>
.vignette {
background:lightblue;
border-color:blue;
border-style:groove;
text-align:center;
min-width:200px;
}
.vignette a{
text-decoration:none;
font-size:16px;
color:black;
}
.vignette a:hover {
background:darkblue;
color:yellow;
}
</style>
</head>
<body>
</body>
<script>
ch = '';
obj = document.styleSheets;
if (obj && obj.length > 0) {
alert(obj.length+' styles');
}
for (i=0; i<obj.length; i++) {
for (j=0; j<obj[i].rules.length; j++) {
ch += obj[i].rules[j]+' '+obj[i].rules[j].selectorText+',';
}
}
document.write('resultat: '+ch);
</script>
</html>

la console javascript m'indique:
obj[i].rules has no properties

Ou est le schmilblic?
Merci

1 réponse

Avatar
YD
je n'arrive pas à récupérer mes styles dans firefox
[...]
la console javascript m'indique:
obj[i].rules has no properties

Ou est le schmilblic?


Pour Firefox c'est cssRules et non rules...

donc obj[i].cssRules


--
Y.D.