By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 1,005 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

cssRules No Longer Works in FireFox 1.5

P: n/a
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.

Jan 22 '06 #1
Share this Question
Share on Google+
19 Replies


P: n/a


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/
Jan 22 '06 #2

P: n/a
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.

Jan 23 '06 #3

P: n/a


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/
Jan 28 '06 #4

P: n/a
VK

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

Jan 28 '06 #5

P: n/a
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
Jan 28 '06 #6

P: n/a
VK

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...

Jan 28 '06 #7

P: n/a
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
Jan 28 '06 #8

P: n/a
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.
Jan 28 '06 #9

P: n/a
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.
Jan 28 '06 #10

P: n/a
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
Jan 29 '06 #11

P: n/a
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.
Jan 29 '06 #12

P: n/a
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
Jan 29 '06 #13

P: n/a
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
Jan 29 '06 #14

P: n/a
VK

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

Jan 30 '06 #15

P: n/a
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:11**********************@g14g2000cwa.googlegr oups.com]
|
| > 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:26****************@PointedEars.de]
|
| > 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
Jan 30 '06 #16

P: n/a
VK

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.

Jan 30 '06 #17

P: n/a
"VK" <sc**********@yahoo.com> 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 - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jan 30 '06 #18

P: n/a
VK

Lasse Reichstein Nielsen wrote:
"VK" <sc**********@yahoo.com> 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=javascrip t.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.

Feb 1 '06 #19

P: n/a
VK wrote:
Lasse Reichstein Nielsen wrote:
"VK" <sc**********@yahoo.com> 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
Feb 1 '06 #20

This discussion thread is closed

Replies have been disabled for this discussion.