[Javascript] detecting CSS capability
Paul Novitski
paul at novitskisoftware.com
Fri May 14 20:42:59 CDT 2004
Friends,
I'm wondering about the various ways it might be possible to detect whether
CSS is functional within a browser, and how dependable any of those checks
might be.
Such tests, of course, would not check for the presence of inline styles or
a stylesheet link in html, but rather would attempt to determine whether
the browser is cognizant of them or acts on them. Here's what I've come up
with so far:
A browser might be CSS-enabled if any of the following are true:
- if the collection document.styleSheets exists in the DOM
- If any DOM object has the 'style' property
- If any DOM object has the 'currentStyle' property
- If any DOM object has the 'runtimeStyle' property
It *might* be possible to detect whether any object has been modified by
CSS, although my experiments haven't revealed the way. CSS affects
presentation, not object content, and client-side scripts appear not to be
aware of the presentation of objects (except through their style
settings). CSS cannot remove or add objects to the DOM for javascript to
detect.
CSS2 does include the :before and :after pseudo-elements which appear to
insert content, but again this content is purely visual presentation and
does not change the innerText or innerHTML of objects to which it is applied.
Any suggestions?
Thanks,
Paul
More information about the Javascript
mailing list