Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

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

This topic is 4872 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!