Return the background color of a document:
alert(document.body.style.backgroundColor);
<!DOCTYPE html> <html> <body style="background-color:yellow;"> <h1>Hello World!</h1> <button type="button" onclick="myFunction()">Get background color</button> <p id="demo"></p> <script> function myFunction() {/*from w w w .java2 s. c om*/ document.getElementById("demo").innerHTML = document.body.style.backgroundColor; } </script> </body> </html>