lincsimp
07-12-2004, 01:27 PM
hi
Does anyone how how to access css properties from javascript, can it be done?
thanks
Does anyone how how to access css properties from javascript, can it be done?
thanks
|
Click to See Complete Forum and Search --> : Css properties from javascript lincsimp 07-12-2004, 01:27 PM hi Does anyone how how to access css properties from javascript, can it be done? thanks AdamGundry 07-12-2004, 01:45 PM You can use the various style (http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/style.html) objects. Adam fredmv 07-12-2004, 01:53 PM Originally posted by AdamGundry You can use the various style (http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/style.html) objects.I think those only ever worked in Netscape 4.x. In any case, you can access CSS rule values via the inline style property, or get computed styles using DOM2 CSS. lincsimp 07-12-2004, 01:55 PM thx very much They seem to work in ie6 too. fredmv 07-12-2004, 05:22 PM Originally posted by lincsimp They seem to work in ie6 too.That couldn't possibly be true. All of those properties are specific to Netscape 4.x. Meaning they only ever worked in Netscape 4.x was out and further, when Gecko (Mozilla) was released (Netscape 6.0+) they were dropped. They couldn't possibly have ever worked in IE. I've done typeof checks on all properties, and under Mozilla 1.7/Firefox 0.9 they all return, as expected, undefined. To access inline styles as I said before, use the style property:<div id="foo" style="color: red;">Hello, World!</div>var fooColor = document.getElementById('foo').style.color; // "red"Or, to grab computed or otherwise non-inline styles:<div>Hello, World!</div>var fooDisplay = document.defaultView.getComputedStyle(document.getElementById('foo'), null).getPropertyValue('display'); // "block" AdamGundry 07-13-2004, 04:03 AM Sorry, I should have been clearer. I was referring to the style property Fred mentioned, which returns a style object containing the properties listed on Netscape's site. Just ignore the "Created By" section of the NS docs. I guess I should have given an example. Adam webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |