Re: How to detect if CSS is disabled?

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 UTC