Thank you for the Safari tip! I’ll add that to the function I currently use. Regarding the default color, I did catch that issue and return white (#ffffff) when I reach the BODY tag (and still get transparent); I’m still left wondering if this will produce weird results on some browser(s), perhaps because of a user preference / override of the default.. I’ll be sure to clean up the code a bit and submit my current solution in the feature request.
Regarding a supplement to getStyle: I’d like to think that getStyle(…, “background-color”) would always return the true style setting, whether transparent or other; however, I’d love to see a pseudo style like “visible-background-color” that would return the actual color seen by the human… although, additionally I can see a use for “visible-background-color-overlapped”, which would return true or false, indicating whether a background-image is present that would overlap some or all of the background-color.
While these pseudo styles *may* be beyond the scope of the YAHOO.util.Dom.getStyle function, they certainly would come in handy from time to time. I hope they will at least be considered. :D
Sent: Friday, September 01, 2006 3:19 PM
There is no YUI pre-canned solution for this currently, but I've thought about supplementing Dom.getStyle for backgroundColor to account for this. If you think this would be a useful enhancement, please add a feature request: http://sourceforge. net/tracker/ ?group_id= 165715&atid=836479.
Your approach of crawling the parentNodes and using Dom.getStyle( ) to find a value other than 'transparent' will work to get the inherited color, except for Safari, which returns "rgba(0, 0, 0, 0)" for transparent, so you'll have to test for that as well. In the case where no backgroundColor is found, you may want to provide a default color.
Joseph Woolley wrote:
Thank you for your reply and the tip! Works great!
Now, I’m wondering if there is a YAHOO-ish way to obtain THE background color, taking into account the parent nodes; meaning, if the style ‘background-color’ is transparent, walk up the parentNode(s) until a non-transparent color specification is found.
Sent: Thursday, August 31, 2006 10:59 PM
My last post had no body it seems? I guess the rich-text editor
doesn't work in firefox 2 beta. Any you can try this:
YAHOO.util.Dom. setSyle(' background- color', '');
Using dashes is IE friendly and the Dom class "camelizes" them for
> In YAHOO.util.Event._unload(e, me) what does the "me" parameter do?
> Could it be removed?