Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7862425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:07:27+00:00 2026-06-02T23:07:27+00:00

How can i access the style declaration of an element specified using external or

  • 0

How can i access the style declaration of an element specified using external or embedded stylesheet.For ex: how to access the width property of an element which is defined in an embeded stylesheet using the id selector..
I know CSSRules object can do this…But it is browser dependent.For ex:in chrome ,the object is null…So what is the browser independent way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:07:28+00:00Added an answer on June 2, 2026 at 11:07 pm

    This is really browser dependent… I have a bit of code which I use to make an auto-expand text area, adapted from code found there.

    Note, the $ function here is from Prototype.

    function getStyleFromCss(el, style) {
        /* Hack required by IE */
        var value = $(el).getStyle(style);
        if (!value) {
            /* For other browsers. Actually this equals 'window'. Use that
             *  if Opera fails on you. */
            if(document.defaultView) {
                value = document.defaultView.getComputedStyle(el, null).
                    getPropertyValue(style);
                // for IE
            } else if(el.currentStyle) {
                value = el.currentStyle[style];
            }
        }
        if(value.length > 0){
            /* if the value returned has the word px in it, we check for
             *  the letter x */
            if (value.charAt(value.length-1) == "x") {
                value = parseInt(value.substring(0, value.length-2));
            }
        }
        return value;
    }
    

    The getStyle() function from Prototype is defined this way, you should be able to easily adapt it to your needs.

    getStyle: function(element, style) {
      element = $(element);
      style = style == 'float' ? 'cssFloat' : style.camelize();
      var value = element.style[style];
      if (!value || value == 'auto') {
        var css = document.defaultView.getComputedStyle(element, null);
        value = css ? css[style] : null;
      }
      if (style == 'opacity') return value ? parseFloat(value) : 1.0;
      return value == 'auto' ? null : value;
    },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am aware that I can access all external links on a page using
I can access this CSS stylesheet from sub-category (folder) by: <link rel=stylesheet type=text/css href=../style.css
I know you can access page resources by using the following code: btn.Style =
I can access Spring beans in my Servlets using WebApplicationContext springContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); in
We can access the valueStack (and other objects of ActionContext ) using OGNL but
Can anyone let me know how can access an element of a list that
As you know anyone can access strings in an native application using a hex
How can I access instance variables in closure(inner function) for this style: this['varName'] ?
This is how you access the <body> element to set a background style: document.body.style.background
I know I can access the head section of a page which uses a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.