Link to home
Start Free TrialLog in
Avatar of rouxjean
rouxjean

asked on

Detect CSS

Is there a way to detect if CSS is enabled or not using ASP ?
Thanks
SOLUTION
Avatar of AgentSmith007
AgentSmith007

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rouxjean
rouxjean

ASKER

Looking for free solution...
Good luck, though that requirement should be stated in your question post in the future.
I hope this may helps you

 <!--
// == ########################  This Script Free To Use Providing This Notice Remains ######################## == //                                                                
// == This Script Has Been Found In The http://www.DesignerWiz.com Javascript Public Archive Library == //
// == NOTICE: Though This Material May Have Been In A Public Depository, Certain Author Copyright Restrictions May Apply == //
--><SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var csspage = "http://www.your-site.com/ccs-page.html";
var nocsspage = "http://www.your-site.com/no-ccs-page.html";
var vers = navigator.appVersion;
vers = vers.substring(0,1);
if (vers >= 4) window.location = csspage;
else window.location = nocsspage;
//  End -->
</script>

http://www.aspsimply.com/admin/aspcode.asp?code=/info/detect2.asp

http://www.designerwiz.com/mf.htm?http&&&www.designerwiz.com/JavaScripts/js_framebrowser_window_master.htm
rk_radhakrishna : ASP...not javascript...also the ASP link do not detect CSS but other stuff !
ok, carry on.................
CSS enabled is dependant on browser version. You should look in the HTTP_USER_AGENT server variable and check which browser version the user is running, if it is less than the version that allows CSS you know you can't use it
try this

<script>
if (document.styleSheets){
alert('good!');}
else{
alert('bad!');
}
</script>



hongjun
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
chisholmd: I want server side detection, where could I find which browser supports CSS (complete list so I can implement it with my browsing sniffing code) ?
Where is your audience? North America? Europe? Elseware?  

http://www.utoronto.ca/ian/books/xhtml2/exerpt/css-4a.html
Why do you need to detect support for CSS? And why do you think there might still be visitors using old browsers?
chisholmd: Mainly North America. My site will rely exclusively on heavy CSS use, don't want them to enter my site if they don't have CSS enabled.
Ok,  If you use Firefox download the web developer extension.  It is very usefull.  Among other features you can disable CSS with a click to see what you site would look like without CSS.

If they won't have CSS you just want them to go away? Or you want them to see a message saying upgrade your browser etc?

you could do something like this.

<span class='hidethis'>Your browser does not support CSS<br /><br /><br /><br />...</span>
then in your css

.hidethis{
 display:none:
}

So if they have CSS support they won't see the message.  

IMHO (and based on my logs from a site with 50,000 visitors a month) you don't need to worry to much about non-css browsers in North America.  Your bigger concern should probably be inconsistant CSS behaviors between NS6/7 , IE, Firefox, etc.



chisholmd: yeah, it's a pain in the a** cross-browser compatibility. Again, I was wondering if I could do this serverside. You can check out my other question here (javascript) :
https://www.experts-exchange.com/questions/21225151/Extensive-CSS-Support-detection.html
So for resume, it is not possible using ASP right ? (besides getting browser name and comparing it to a CSS compatible Browser list)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Check the other link.  I think detecting CSS support is the wrong way to go. The browsers are not that far apart on CSS and unlike javascript its easy to include two different directives and which ever is supported by the browser should work.

I can't think of a good example off the top of my head but imagine the follwing fictious css directives.
.class{
    foo: show;
    foo: visible;
}

I think that whichever directive is not supported will just be ignored.

Usaully its something else like...
.class{
    foo: show;
    snee: visible;
}

For some reason with NS6 I found that if I included the directive in-line rather then in a external CSS.
.class{
     foo: visible;
  }
Wouldn't work but
< style="foo: visible">  would work


Ok I'm rambling.  The point is, test on different browsers and modify CSS accordingly.



chisholmd: My point is that my CSS will work on all browsers. But if the CSS isn't supported, my site won't work ! For example, I have tab menus which rely exclusively on CSS. If it's not enabled or part of the CSS isn't enabled, you can imagine what a mess it is ! So I need some way to detect if CSS is enabled....I do understand your point though.
On the link I posted (of my other question) part of the job is done in javascript, just need further tweaking, out of my abilities.
I just a little test using firefox, I went to a bunch of sites and disables CSS.  Most looked like crap in one way or another.  

I know I am answering your question by trying to unask it but nonetheless I would focus on making sure your CSS and HTML validate and not worry about those without CSS unless you suspect they makeup a larger then normal portion of your audience. Typical North Americian visitors support CSS because they have upgraded their browsers for security reasons.  I am ready to be corrected by someone with another opinion.

http://jigsaw.w3.org/css-validator/
http://validator.w3.org/

Whats the site btw?



@rouxjean

I realized you asked a question in Sep 2003 "Detect if CSS is enabled ?" and had got valuable feedback. Wondering why ask the same question again? It appears to me this question is not going anywhere.
https://www.experts-exchange.com/questions/20745677/Detect-if-CSS-is-enabled.html


hongjun
@hongjun: again, this question is about finding a serverside method, using ASP. My old post was about Javascript.
@chisholmd: don't worry I test my pages on a lot of different computers.

It is my understanding that it can't be done with ASP.....even though BrowserHawk seems to be able to do it...
That's false advertising then :-)
Thanks
Well I wouldn't say that.  First of all I am only supposing that this is how it works. Second for you the programmer I imagine it functions as a server side tool.  

I also realized that I shouldn't have posted that snippet of thier code as I have porbably violated thier copywrite and I will be asking a moderator to remove it post haste.

Cheers,


I don't think so...   :)
davidlars99:  You don't think it's a copywrite infringement ?  I not then I think you'd better read up on intellectual property laws.  I can't believe I was so stupid as to post it in the first place.  BrowserHawk is an excellent product and my comments about it were meant as educational and not as a statement about its worthiness.

Oh I just scrolled up and the most excellent moderator has removed my offending post already, hiphip for that i can breath again :)

Later
you were holding your breath since you've posted that comment, you're really good...
:) lol, well I'm alergic to lawsuites

>>again, this question is about finding a serverside method, using ASP. My old post was about Javascript
But one of the answers http:Q_21224733.html#12709449 you accepted appears to be javascript based.
Moreover, it is very similar to mine http:Q_21224733.html#12707596



hongjun