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 7978893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:36:59+00:00 2026-06-04T09:36:59+00:00

After calling window.getComputedStyle , how can I tell whether a style a style is

  • 0

After calling window.getComputedStyle, how can I tell whether a style a style is from the page itself (rather than being from the browser)? I’m interested in doing so in pure javascript, though I would settle for a solution which ran in the context of an add-on.

  • 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-04T09:37:00+00:00Added an answer on June 4, 2026 at 9:37 am

    You will have a hard time figuring out where the rules that getComputedStyle gives you came from. Note that the code provided by MaxArt isn’t a complete solution – there are also inherited styles so one would have to repeat everything for parent nodes. The simpler approach would be using inIDOMUtils.getCSSStyleRules(), along these lines:

    function isPageStyle(styleSheet)
    {
      if (styleSheet.ownerNode)
        return true;
    
      if (styleSheet.ownerRule instanceof Components.interfaces.nsIDOMCSSImportRule)
        return isPageStyle(styleSheet.parentStyleSheet);
    
      return false;
    }
    
    var domUtils = Components.classes["@mozilla.org/inspector/dom-utils;1"]
                             .getService(Components.interfaces.inIDOMUtils);
    var rules = domUtils.getCSSStyleRules(element);
    for (var i = 0; i < rules.Count(); i++)
    {
      var rule = rules.GetElementAt(i);
      if (isPageStyle(rule.parentStyleSheet))
        alert(rule.cssText);
    }
    

    You will have to do it for the parent nodes as well. For a complete example you can look at the implementation of the Inspector feature in Firefox (isPageStyle function in my answer shamelessly “borrowed” from here).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'v created a window after creating my main one but calling DestroyWindow on its
I want to close a popup window from an error page. The process is:
I have a Window instance which I show by calling wInstance.ShowDialog() from a button
I'm loading some picture from server by JS after whole page is loaded. Means
It seems after calling history.pushState, window.location.pathname doesn't get changed (at least in Safari). Any
I created a new email-message using Redemption-Data-Objects in C#. After calling Display(), the window
I'm trying to remove a UITabBarController from a window in my app by calling
I am having a problem with Vlad on windows. After calling rake vlad:deploy I
After calling notifydatasetchanged(); I want to scroll to the bottom of list so that
After calling to a com component procedure , an error raised OLE error C0000094.

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.