Forum Moderators: open
<body style="background-color:green">
Although it may look like it, the browser will compute the style to be applied by looking at any applied style definitions in the document that apply for the tag in question.
Unfortunately there is no easy answer to this one. Especially when you take into account the various browsers available.
This would come close.
var bdy=document.getElementsByTagName("BODY")[0];if (bdy.currentStyle)
var y = bdy.currentStyle["backgroundColor"];
else if (window.getComputedStyle)
var y = Window.getComputedStyle(bdy,"")["backgroundColor"];
alert(y);
Something else you'll have to bear in mind is that some browsers will return the colour in Hex notation (such as "#00FF00" for green),
Whereas others will return RGB notation (such as "rgb(0,128,0)" for green). Or you may even get a word (such as "green")