W3C home > Mailing lists > Public > www-style@w3.org > June 2002

Re: How to detect if CSS is disabled?

From: Stuart Ballard <sballard@netreach.com>
Date: Tue, 25 Jun 2002 09:19:55 -0400
Message-ID: <3D186DFB.7010209@netreach.com>
To: Boris Zbarsky <bzbarsky@MIT.EDU>
CC: Rick Hill <rrhill@ucdavis.edu>, www-style@w3.org

Boris Zbarsky wrote:
>>Is it possible to detect if a browser's CSS has been disabled?
> 
> 
> You mean how to detect that the user-agent sheets are not being applied
> at all?  There is no way to do it, and furthermore it would tell you
> nothing useful if there were.....

I assumed he meant whether the equivalent of NS4's "Disable CSS" had 
been selected by the user - ie, that *author* sheets aren't being applied.

In which case there isn't a *good* way to do it but you can detect it by 
virtue of the fact that CSS stylesheets can have side effects. For example:

<div id="dummy">
</div>

#dummy {
   background-image: url(myimage.gif?sessionId=...)
}

If "myimage.gif" gets requested from your server with a particular 
session id, then the user with that session has CSS enabled. Otherwise 
he doesn't (or perhaps is using a non-graphical browser that supports 
CSS but not images? Are there any such?)

Of course, you can't get that information in time to change the content 
of the page based on it... And it would take some serious server-side 
hacking to use it for anything useful at all. But strictly speaking, it 
is an answer to the question ;)

Stuart.


-- 
Stuart Ballard, Programmer
NetReach - Internet Solutions
(215) 283-2300, ext. 126
http://www.netreach.com/
Received on Tuesday, 25 June 2002 09:19:59 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:14 GMT