Bonjour,
Je cherche à récupérer la valeur de background-color de la balise body.
J'utilise la fonction getComputedStyle mais ça ne fonctionne pas.
Voici le code :
La fenêtre alert ne s'ouvre pas.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 <html lang="fr-fr"> <head> <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" /> <title>Page de test</title> <style type="text/css"> body { background-color: rgb(173, 216, 230); color: #4A4E53; margin: 0; padding: 0; } </style> <script type="text/javascript"> var bodi = document.getElementsByTagName("body"); var b_style = document.defaultView.getComputedStyle(bodi, null).getPropertyValue("background-color"); alert (b_style); </script> </head> <body> <h2>Bonjour</h2> </body> </html>
Merci pour votre aide.
Partager