Juri Shutenko

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromJuri Shutenko
ToMe
SubjectError in the article "DOM Style Sheets"
Date24 September 2006 12:38
Hallo, Mark!

Unfortunatelly there is the one error inside you article:
http://www.howtocreate.co.uk/tutorials/javascript/domstylesheets

[quote]
Test it here: add the new rule 'p { color: lime; }', and then delete it
again
[/quote]

MS Internet Explorer supports the stylesheets collection,
but your test shown that is wrong, so check, please, this part
of your excellent article.

WBR
Juri
FromMe
ToJuri Shutenko
SubjectRe: Error in the article "DOM Style Sheets"
Date24 September 2006 14:30
Juri,

> MS Internet Explorer supports the stylesheets collection,
> but your test shown that is wrong, so check, please, this part
> of your excellent article.

When I try the test in IE (windows or mac), it says "Your browser does not
support DOM 2 Style Sheets". That is correct. IE supports the
document.styleSheets collection, but it does not support W3C DOM 2
StyleSheets. It has its own model that is incompatible with W3C DOM 2.

In browsers that do not support either model - such as Opera 8 or below - it
says "Your browser does not support document.styleSheets". I do not get that
message in IE, so I do not see anything wrong with my script.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromJuri Shutenko
ToMe
SubjectRe: Error in the article "DOM Style Sheets"
Date24 September 2006 20:11
Hi, Mark!

I mean that code for checking
"if( !document.styleSheets ) { showNoSSWarning(); return; }"
not correct, because expression "!document.styleSheets" returns false at
execution and document.styleSheets in IE is an object, if we have loaded
CSS by link rel=stylesheet.

Or I wrong?
WBR
Juri
FromMe
ToJuri Shutenko
SubjectRe: Error in the article "DOM Style Sheets"
Date24 September 2006 20:56
Juri,

> "if( !document.styleSheets ) { showNoSSWarning(); return; }"
>
> Or I wrong?

You misunderstand. That line says "If the browser does not support
document.stylesheets, show the warning that says it does not support
document.stylesheets".

That is line that is triggering in Opera 8. In IE, it is this line that
triggers:

if( !oStyleSheet.insertRule || !oStyleSheet.cssRules ||
!oStyleSheet.cssRules.length ) { showNoDOMSSWarning(); return; }

The checks are done in stages to catch all the possible ways that a browser
can fail to support DOM 2 StyleSheets. Opera 8 and browsers like it are
stopped by the first check, IE is stopped at the last one. They have
different warnings depending on what fails;
showNoSSWarning
showNoSSFoundWarning
showNoDemoWarning
showNoDOMSSWarning

In a real script, you would obviously not need to have so many separate
checks, I only use them as part of the demonstration so you can see how a
browser has failed when it fails.
FromJuri Shutenko
ToMe
SubjectRe: Error in the article "DOM Style Sheets"
Date24 September 2006 21:30
Hi,Mark!
Thanks a lot for time You spent with my questions and your explanations.

WBR
Juri

When we'll have a time that all browsers will support all standards? :)
Thanks once more!
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.