"Aaron Gray" <ang.usenet@gmail.com> wrote in message
news:3u3nptFv7985U1@individual.net...
> "Aaron Gray" <ang.usenet@gmail.com> wrote in message
> news:3u3njpFvept8U1@individual.net...
>> Well I have gone and done it, got to the bottom of it.
>>
>> Nothing spectacular but its good to see how it is done.
>>
>> Now to distill the brew ...
>
> First up 'SetClassStyle()' :-
>
> //
> // SetClassStyle() - Sets a classes style to a value
> //
> // Works pre stylesheet by setting the style of all elements of the
> particular class.
> //
>
> function SetClassStyle( clazz, style, value)
> {
> if (document.styleSheets)
> {
> clazz = "." + clazz;
>
> for( var styleSheetNo = 0; styleSheetNo < document.styleSheets.length;
> styleSheetNo++)
> {
> var styleSheet = document.styleSheets[styleSheetNo];
> var rules = styleSheet.rules | styleSheet.cssRules;
>
> if (!rules) return; // err ???
>
> for ( var rule = 0; rule < rules.length; rule++)
> if ( rules[rule].selectorText.toLowerCase() == clazz)
> rules[rule].style[style] = value;
> }
> }
> else // No stylesheet
> {
> var all = getElementByTagName("*");
>
> for ( var element = 0; element < all.length; element++)
> if ( all[element].className == clazz)
> all[element].style[style] = value;
> }
> }
>
> Anyone enlighten me on the cop out return statement, 'err ???'.
>
> Should it stay or should it go. Or what ?
>
> Aaron
>
>
>
Received on Mon Nov 21 03:32:38 2005