Sign in to follow this  
johnnyBravo

[web] How to get css(external) values using javascript?

Recommended Posts

Hi, I want to get the values eg like obj.style.width, from the style sheet. Except the css file is external, so it just returns 0 from what i wrote above. Anyway I tried using: window.getComputedstyle which only works for netscape/firefox and obj.currentstyle which only works for ie. So I was wondering if there are any other ways to get a value from the stylesheet that works with most browsers? For example in a scenario like this: /*css file */ input.textfield {width:5em;} <-- html file --> <input type="text" class="textfield" name="obj" id="obj" /> thanks

Share this post


Link to post
Share on other sites
Look into the stylesheet collection of the DOM Document Object. Using this you can evaluate the rules in an external style sheet.


If you have Firefox installed you can use the DOM Inspector to browse the javascript objects and see more details about the stylesheet collection.

[Edited by - Easca on February 17, 2005 1:04:53 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this