cssRules No Longer Works in FireFox 1.5

Discussion in 'Javascript' started by mephraim, Jan 22, 2006.

  1. mephraim

    mephraim Guest

    I have a WYSIWYG editor based on the HTMLArea project that uses the
    cssRules object of a stylesheet to add/update stylesheet rules for
    table cells. Ever since I upgraded to FireFox 1.5, I get the following
    error message when trying to access the cssRules object:

    "Access to restricted URI denied"

    The code I am trying to execute looks like this:

    var currStyleSheet = editor._doc.styleSheets[0];
    var currRules = currStyleSheet.cssRules;
    var tdIndex = currRules.length;
    for(i = 0; i < currRules.length; i++) {
    if(currStyleSheet.cssRules.item(i).type == 1) {
    //if it is a style rule
    var currRule = currRules.item(i)
    if (currRule.selectorText.toLowerCase() == "td") {
    tdIndex = i;
    }
    }

    }

    This code is simply looking for any rules for TD elements. I am at a
    loss as to what is going on and/or what changed if FireFox to cause
    this error. It worked fine in previous releases of FireFox. The
    document that I am trying to access the stylesheet for is within an
    IFRAME, which is what I believe is causing the problem. Thanks.
     
    mephraim, Jan 22, 2006
    #1
    1. Advertising

  2. mephraim wrote:

    > I have a WYSIWYG editor based on the HTMLArea project that uses the
    > cssRules object of a stylesheet to add/update stylesheet rules for
    > table cells. Ever since I upgraded to FireFox 1.5, I get the following
    > error message when trying to access the cssRules object:
    >
    > "Access to restricted URI denied"
    >
    > The code I am trying to execute looks like this:
    >
    > var currStyleSheet = editor._doc.styleSheets[0];
    > var currRules = currStyleSheet.cssRules;


    Does the error message not name the exact line number causing the error?
    which line is that, the attempt to access
    editor._doc
    or the attempt to access
    currStyleSheet.cssRules

    What is the URL of the HTML document with the script, what is the URL of
    the iframe? As the error message says "Access to restricted URI denied"
    seeing the URIs could help.



    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jan 22, 2006
    #2
    1. Advertising

  3. mephraim

    mephraim Guest

    The error occurrs on the line with the following:

    var currRules = currStyleSheet.cssRules

    I am able to read the stylesheet, but it throws that error when I try
    to access cssRules.

    I am running this page on a development server
    (http://niagara.leepfrog.com/), and the IFRAME is populated with a
    series of iframe.document.write() calls, not a SRC. It works when I
    try to access cssRules from the main Document sylesheet, but throws the
    error when I try to access cssRules in the IFRAME from the Main
    Document. Hopefully this clears thins up a little bit.
     
    mephraim, Jan 23, 2006
    #3
  4. mephraim wrote:

    > The error occurrs on the line with the following:
    >
    > var currRules = currStyleSheet.cssRules
    >
    > I am able to read the stylesheet, but it throws that error when I try
    > to access cssRules.
    >
    > I am running this page on a development server
    > (http://niagara.leepfrog.com/), and the IFRAME is populated with a
    > series of iframe.document.write() calls, not a SRC.


    Do you still experience the problem? Do you have a URL with the example?


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jan 28, 2006
    #4
  5. mephraim

    VK Guest

    mephraim wrote:
    > I have a WYSIWYG editor based on the HTMLArea project that uses the
    > cssRules object of a stylesheet to add/update stylesheet rules for
    > table cells. Ever since I upgraded to FireFox 1.5, I get the following
    > error message when trying to access the cssRules object:
    >
    > "Access to restricted URI denied"
    >
    > The code I am trying to execute looks like this:
    >
    > var currStyleSheet = editor._doc.styleSheets[0];
    > var currRules = currStyleSheet.cssRules;
    > var tdIndex = currRules.length;
    > for(i = 0; i < currRules.length; i++) {
    > if(currStyleSheet.cssRules.item(i).type == 1) {
    > //if it is a style rule
    > var currRule = currRules.item(i)
    > if (currRule.selectorText.toLowerCase() == "td") {
    > tdIndex = i;
    > }
    > }
    >
    > }


    Uhmm... and who told you that ever worked for Firefox at all? Did you
    get yours from mozilla.org ?

    Presuming that your style sheet has an ID (the only way to work
    reliably with Firefox) and this ID is say "myCSS" then:

    document.getElementById('myCSS').sheet.cssRules[0].style.backgroundColor;
    and so on...

    Works just fine since 1.0.4
     
    VK, Jan 28, 2006
    #5
  6. VK wrote:

    > mephraim wrote:
    >> I have a WYSIWYG editor based on the HTMLArea project that uses the
    >> cssRules object of a stylesheet to add/update stylesheet rules for
    >> table cells. Ever since I upgraded to FireFox 1.5, I get the
    >> following error message when trying to access the cssRules object:
    >>
    >> "Access to restricted URI denied"
    >>
    >> The code I am trying to execute looks like this:
    >>
    >> var currStyleSheet = editor._doc.styleSheets[0];
    >> var currRules = currStyleSheet.cssRules;
    >> var tdIndex = currRules.length;
    >> for(i = 0; i < currRules.length; i++) {
    >> if(currStyleSheet.cssRules.item(i).type == 1) {
    >> //if it is a style rule
    >> var currRule = currRules.item(i)
    >> if (currRule.selectorText.toLowerCase() == "td") {
    >> tdIndex = i;
    >> }
    >> }
    >>
    >> }

    >
    > Uhmm... and who told you that ever worked for Firefox at all?


    It is specified so.

    > Did you get yours from mozilla.org ?


    Obviously you did not.

    > Presuming that your style sheet has an ID (the only way to work
    > reliably with Firefox)


    Nonsense, Firefox (i.e. the Gecko DOM) provides the document.styleSheets
    collection (a reference to a StyleSheetList object) accessed here as
    specified in W3C DOM Level 2 Style.

    > and this ID is say "myCSS" then:
    >
    > document.getElementById('myCSS').sheet.cssRules[0].style.backgroundColor;
    > and so on...


    Nonsense:

    > Works just fine since 1.0.4


    Of course it does not. A CSSStyleSheet object referred to by the return
    value of document.getElementById() here does not have a 'sheet' property
    at all. What would also work instead is

    document.getElementById('myCSS').cssRules[0].style.backgroundColor;

    However this required an ID while the document.styleSheets collection did
    not. Unfortunately as usual, the information you provided is factually
    flawed and therefore potentially harmful to others.


    PointedEars
     
    Thomas 'PointedEars' Lahn, Jan 28, 2006
    #6
  7. mephraim

    VK Guest

    Thomas 'PointedEars' Lahn wrote:
    > However this required an ID while the document.styleSheets collection did
    > not. Unfortunately as usual, the information you provided is factually
    > flawed and therefore potentially harmful to others.


    as usual 2 months of experiments are defited by one specs reading...
     
    VK, Jan 28, 2006
    #7
  8. VK wrote:

    > Thomas 'PointedEars' Lahn wrote:
    >> However this required an ID while the document.styleSheets collection did
    >> not. Unfortunately as usual, the information you provided is factually
    >> flawed and therefore potentially harmful to others.

    >
    > as usual 2 months of experiments are defited by one specs reading...


    What are you babbling about? The Gecko DOM does _not_ specify nor
    _implement_ a `sheet' property for CSSStyleSheet objects. However, it has
    specified _and_ has _implemented_ the document.styleSheets collection ever
    since.

    <URL:http://developer.mozilla.org/en/docs/DOM:style>

    If your tests showed the opposite, then your tests are flawed. Which would
    not be surprising, though.


    PointedEars
     
    Thomas 'PointedEars' Lahn, Jan 28, 2006
    #8
  9. On 28/01/2006 17:36, Thomas 'PointedEars' Lahn wrote:

    > VK wrote:


    [snip]

    >> Uhmm... and who told you that [styleSheets and cssRules
    >> collections] ever worked for Firefox at all?

    >
    > It is specified so.


    Quite right, though more importantly, it is implemented as such (since
    at least Moz 1.3 - the earliest Gecko browser I have available at the
    moment).

    [snip]

    > Nonsense, Firefox (i.e. the Gecko DOM) provides the
    > document.styleSheets collection (a reference to a StyleSheetList
    > object) accessed here as specified in W3C DOM Level 2 Style.


    Again, very true.

    [snip]

    > A CSSStyleSheet object referred to by the return value of
    > document.getElementById() here does not have a 'sheet' property at
    > all.


    An object implementing the CSSStyleSheet interface does not have a sheet
    property, as you say, but a LINK or STYLE element that references a
    cascading style sheet doesn't implement the CSSStyleSheet interface
    directly. Instead, they both implement the LinkStyle interface, which
    only has one property, sheet (and that does implement the StyleSheet
    interface).

    > What would also work instead is
    >
    > document.getElementById('myCSS').cssRules[0].style.backgroundColor;


    You should have tested that; it doesn't (though I'm guilty of the same
    charge on occasions when I'm feeling lazy :-/).

    [snip]

    It seems to me that this should be a security issue: the OP is trying to
    access style sheet rules from an IFRAME element that isn't part of the
    same domain (from the description, there's no URL). That said, I thought
    security issues started when trying to access the document object[1].

    Mike


    [1] I don't 'do' frames, so I'll plead ignorance, here. It's a
    potential starting point, though.

    --
    Michael Winter
    Prefix subject with [News] before replying by e-mail.
     
    Michael Winter, Jan 28, 2006
    #9
  10. On 28/01/2006 20:30, VK wrote:

    [snip]

    > as usual 2 months of experiments are defited by one specs reading...


    It took you two months to conclude that the Gecko DOM doesn't support
    the styleSheets collection, when in fact it does?

    Mike

    --
    Michael Winter
    Prefix subject with [News] before replying by e-mail.
     
    Michael Winter, Jan 28, 2006
    #10
  11. Michael Winter wrote:

    > On 28/01/2006 17:36, Thomas 'PointedEars' Lahn wrote:
    >> VK wrote:
    >>> Uhmm... and who told you that [styleSheets and cssRules
    >>> collections] ever worked for Firefox at all?

    >>
    >> It is specified so.

    >
    > Quite right, though more importantly, it is implemented as such (since
    > at least Moz 1.3 - the earliest Gecko browser I have available at the
    > moment).


    I think it has been a Gecko DOM feature ever since. However, it is good
    that you mention in works in release version 1.3, too, because the Cross
    Reference at MDC says it worked since 1.4:

    <URL:http://developer.mozilla.org/en/docs/DOM_Client_Object_Cross-Reference:document>

    I guess I should correct this. Could you please post the original
    User-Agent header or navigator.userAgent property value of the Mozilla/5.0
    UA you have tested with?

    >> A CSSStyleSheet object referred to by the return value of
    >> document.getElementById() here does not have a 'sheet' property at
    >> all.

    >
    > An object implementing the CSSStyleSheet interface does not have a sheet
    > property, as you say, but a LINK or STYLE element that references a
    > cascading style sheet doesn't implement the CSSStyleSheet interface
    > directly. Instead, they both implement the LinkStyle interface, which
    > only has one property, sheet (and that does implement the StyleSheet
    > interface).


    Correct.

    >> What would also work instead is
    >>
    >> document.getElementById('myCSS').cssRules[0].style.backgroundColor;

    >
    > You should have tested that;


    I have now and was quite surprised that there is a difference indeed.

    > it doesn't [...]


    You are right. I consider this another reason why one should use
    document.styleSheets instead, if possible.

    > It seems to me that this should be a security issue: the OP is trying to
    > access style sheet rules from an IFRAME element that isn't part of the
    > same domain


    The same _second-level_ domain, to be exact. You can "cheat" the SOP by
    assigning a value to `document.domain'.

    > (from the description, there's no URL).


    Yeah, maybe it is a resource accessed with a http:// URI/URL trying to
    access a resource with a file:// URI.

    > That said, I thought security issues started when trying to access the
    > document object[1].


    That was my assumption as well and as Martin already asked the OP about
    this, I found it unnecessary to ask again. However, since the OP did not
    to post the relevant URIs to date it only stays an educated guess :-/


    Regards,
    PointedEars
     
    Thomas 'PointedEars' Lahn, Jan 28, 2006
    #11
  12. Thomas 'PointedEars' Lahn wrote:
    > Michael Winter wrote:
    >> Thomas 'PointedEars' Lahn wrote:
    >>> VK wrote:
    >>>> Uhmm... and who told you that [styleSheets and cssRules
    >>>> collections] ever worked for Firefox at all?
    >>>
    >>> It is specified so.

    >>
    >> Quite right, though more importantly, it is implemented
    >> as such (since at least Moz 1.3 - the earliest Gecko
    >> browser I have available at the moment).

    >
    > I think it has been a Gecko DOM feature ever since.


    The oldest Gecko browser I have that implements document.styleSheets
    (with cssRules) is 0.9.3, which is as close to being 'ever since' as you
    would want.

    <snip>
    > I guess I should correct this. Could you please post the
    > original User-Agent header or navigator.userAgent property
    > value of the Mozilla/5.0 UA you have tested with?

    <snip>

    Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.3) Gecko/20010801

    Richard.
     
    Richard Cornford, Jan 29, 2006
    #12
  13. Richard Cornford wrote:

    > Thomas 'PointedEars' Lahn wrote:
    >> Michael Winter wrote:
    >>> Thomas 'PointedEars' Lahn wrote:
    >>>> VK wrote:
    >>>>> Uhmm... and who told you that [styleSheets and cssRules
    >>>>> collections] ever worked for Firefox at all?

    >> [...]
    >>
    >> I think it has been a Gecko DOM feature ever since.

    >
    > The oldest Gecko browser I have that implements document.styleSheets
    > (with cssRules) is 0.9.3, which is as close to being 'ever since' as you
    > would want.


    Thanks.

    > <snip>
    >> I guess I should correct this. Could you please post the
    >> original User-Agent header or navigator.userAgent property
    >> value of the Mozilla/5.0 UA you have tested with?

    > <snip>
    >
    > Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.3) Gecko/20010801


    [x] done:
    <URL:http://developer.mozilla.org/en/docs/Talk:DOM_Client_Object_Cross-Reference:document>


    PointedEars
     
    Thomas 'PointedEars' Lahn, Jan 29, 2006
    #13
  14. Richard Cornford wrote:

    > Thomas 'PointedEars' Lahn wrote:
    >> Michael Winter wrote:
    >>> Thomas 'PointedEars' Lahn wrote:
    >>>> VK wrote:
    >>>>> Uhmm... and who told you that [styleSheets and cssRules
    >>>>> collections] ever worked for Firefox at all?

    >> [...]
    >>
    >> I think it has been a Gecko DOM feature ever since.

    >
    > The oldest Gecko browser I have that implements document.styleSheets
    > (with cssRules) is 0.9.3, which is as close to being 'ever since' as you
    > would want.


    Thanks.

    > <snip>
    >> I guess I should correct this. Could you please post the
    >> original User-Agent header or navigator.userAgent property
    >> value of the Mozilla/5.0 UA you have tested with?

    > <snip>
    >
    > Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.3) Gecko/20010801


    [x] done:
    <URL:http://developer.mozilla.org/en/docs/DOM_Client_Object_Cross-Reference:document>


    PointedEars
     
    Thomas 'PointedEars' Lahn, Jan 29, 2006
    #14
  15. mephraim

    VK Guest

    VK wrote:
    > as usual 2 months of experiments are defited by one specs reading...


    "The Sleep of Reason Produces Monsters"
    Francisco de Goya y Lucientes

    document.styleSheets *is* supported by FF 1.5
     
    VK, Jan 30, 2006
    #15
  16. VK wrote:

    > VK wrote:
    >> as usual 2 months of experiments are defited by one specs reading...

    >
    > "The Sleep of Reason Produces Monsters"
    > Francisco de Goya y Lucientes


    You should not quote wisdom that you are incapable to understand.

    > document.styleSheets *is* supported by FF 1.5


    _You_ stated that it is not:

    ,-[news:]
    |
    | > var currStyleSheet = editor._doc.styleSheets[0];
    |
    | [...] and who told you that ever worked for Firefox at all?
    |
    | Presuming that your style sheet has an ID (the only way to work
    | reliably with Firefox) [...]

    And you have been disproven by me:

    ,-[news:]
    |
    | > Presuming that your style sheet has an ID (the only way to work
    | > reliably with Firefox)
    |
    | Nonsense, Firefox (i.e. the Gecko DOM) provides the document.styleSheets
    | collection (a reference to a StyleSheetList object) accessed here as
    | specified in W3C DOM Level 2 Style.

    How more stupid can you possibly act?


    PointedEars
     
    Thomas 'PointedEars' Lahn, Jan 30, 2006
    #16
  17. mephraim

    VK Guest

    Thomas 'PointedEars' Lahn wrote:
    > You should not quote wisdom that you are incapable to understand.
    > How more stupid can you possibly act?


    OK, document.styleSheets doesn't act as *I* would like it to act to,
    but it does act somehow which is OK by me really.
    Over the last 3 months JSONet project had been banned out of all public
    incubators (like http://sourceforge.net/) as soon as I mentioned "Ajax
    free solution". In case of any real or (my troubled mind produced)
    imaginary troubles:

    1) It is possible to transmit any proprietary data over the current CSS
    standards.

    2) Any transmission of such data over the current CSS rules is a public
    domain free GNU-licensed exploit of currently existing public formats.

    3) Anyone willing to copyright this GNU-announced format has to proove
    that his/her idea of data trasmission over CSS took place time before
    this announcement.
     
    VK, Jan 30, 2006
    #17
  18. "VK" <> writes:

    > 2) Any transmission of such data over the current CSS rules is a public
    > domain free GNU-licensed exploit of currently existing public formats.


    That makes no sense, whatsoever.
    The GNU license covers software covered by copyright.
    The method of transmission is an idea, which can not be copyrighted.
    It might be patentable, although I hope not.

    > 3) Anyone willing to copyright this GNU-announced format has to proove
    > that his/her idea of data trasmission over CSS took place time before
    > this announcement.


    As you say: "idea". Ideas are not copyrighted, they are patented.

    /L
    --
    Lasse Reichstein Nielsen -
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
    'Faith without judgement merely degrades the spirit divine.'
     
    Lasse Reichstein Nielsen, Jan 30, 2006
    #18
  19. mephraim

    VK Guest

    Lasse Reichstein Nielsen wrote:
    > "VK" <> writes:
    >
    > > 2) Any transmission of such data over the current CSS rules is a public
    > > domain free GNU-licensed exploit of currently existing public formats.

    >
    > That makes no sense, whatsoever.
    > The GNU license covers software covered by copyright.
    > The method of transmission is an idea, which can not be copyrighted.
    > It might be patentable, although I hope not.


    It is software, not hardware domain, where you need to make something
    blinking and working for (c). In software an idea is often == solution.
    And to destinguish between a bright (or not too much) idea and a
    patentable algorythm is a real puzzle.

    <http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO2&Sect2=HITOFF&p=1&u=/netahtml/search-bool.html&r=2&f=G&l=50&co1=AND&d=pall&s1=javascript.TTL.&OS=TTL/javascript&RS=TTL/javascript>

    Would you believe it? I wouldn't - and I still don't believe that the
    above is practically applicable. But I don't want to repeat the story
    in any shell perform form. It is not about personal benefits or glory -
    the practical usability of what I am doing is a big question. But in
    case if it is usable, I want to prevent any "smart people" like that
    Honkong team from any attempt to take it out of public free domain.

    1) Dynamic CSS file implant (using <LINK>)
    2) CSS file like:
    ..data {
    font-face: fantasy, "JSON%20URLEncoded%20data"
    }
    (there are 7 more style rules which can be used)

    The rest are technical issues of threading and onload monitoring I'm
    working on.

    Cross-domain free.
    Secure - data delivered and parsed as text, you have to explicetly
    convert it into JavaScript
    Support by any browser with full or partial CSS2 support (currently for
    sure FF 1.x, IE 5.5, Camino 1.x)

    > As you say: "idea". Ideas are not copyrighted, they are patented.


    Right, thank you. I have to intention to do neither of both, but terms
    are important.
     
    VK, Feb 1, 2006
    #19
  20. VK wrote:

    > Lasse Reichstein Nielsen wrote:
    >> "VK" <> writes:
    >> > 2) Any transmission of such data over the current CSS rules is a public
    >> > domain free GNU-licensed exploit of currently existing public formats.

    >>
    >> That makes no sense, whatsoever.
    >> The GNU license covers software covered by copyright.
    >> The method of transmission is an idea, which can not be copyrighted.
    >> It might be patentable, although I hope not.

    >
    > It is software, not hardware domain, where you need to make something
    > blinking and working for (c). In software an idea is often == solution.


    Oh please read the GNU GPL and shut up. We (and I am sure I am not the
    only one) had enough of your nonsense now.


    PointedEars
     
    Thomas 'PointedEars' Lahn, Feb 1, 2006
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cory Nelson
    Replies:
    2
    Views:
    421
    Cory Nelson
    Apr 15, 2004
  2. =?Utf-8?B?QnJ5YW4gWk0=?=
    Replies:
    1
    Views:
    1,159
    =?Utf-8?B?QnJ5YW4gWk0=?=
    May 26, 2005
  3. bb
    Replies:
    2
    Views:
    390
  4. Christopher Benson-Manica

    cssRules in IE

    Christopher Benson-Manica, Mar 3, 2005, in forum: Javascript
    Replies:
    1
    Views:
    81
    Evertjan.
    Mar 3, 2005
  5. jgabios
    Replies:
    5
    Views:
    153
    Jeremy J Starcher
    Apr 22, 2009
Loading...

Share This Page