Trouble retrieving backgound color style

admin

Administrator
Staff member
I am accessing Javascript from an Applet using JSObject. I would like to set the background color of my applet to the same color as the background style of the containing element.

To test, I wrote the following test code:

function getPageColor()
{
return document.getElementById( "main" ).style.backgroundColor;
}

I have defined the backgound-color for the "main" element using an external stylesheet.

...
.main{ background-color:white; color:black; font-family: Arial, Helvetica, sans-serif; border:1px solid black}

And the HTML looks like.
<table class='main' id='main' width='800' height='600' border='0' cellpadding='0' cellspacing='0'>

The problem is that the getPageColor method always returns the empty string.

I modified the code to set the background color in javascript, and when I invoke this method it returns the proper result.

Any advice from anyone? Other ways to do this?

Thanks!
av_boy
 
Back
Top