Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 514
  • Last Modified:

Detect CSS

Is there a way to detect if CSS is enabled or not using ASP ?
Thanks
0
rouxjean
Asked:
rouxjean
  • 9
  • 8
  • 4
  • +4
3 Solutions
 
AgentSmith007Commented:
There is a way, however it requires somewhat costly server components: check outt www.browserhawk.com

Click on the MORE button in the top area & it'll tell you more about your system config than you ever wanted to know.
0
 
rouxjeanAuthor Commented:
Looking for free solution...
0
 
AgentSmith007Commented:
Good luck, though that requirement should be stated in your question post in the future.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
rk_radhakrishnaCommented:
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
0
 
rouxjeanAuthor Commented:
rk_radhakrishna : ASP...not javascript...also the ASP link do not detect CSS but other stuff !
0
 
rk_radhakrishnaCommented:
ok, carry on.................
0
 
rk_radhakrishnaCommented:
0
 
justinbilligCommented:
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
0
 
hongjunCommented:
try this

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



hongjun
0
 
chisholmdCommented:
personally I would use hongjun's solution as it does not rely on browser detection it detects css support directly.  However if you must use serverside code here is a snip.  I don't use browser detection anymore for anything. If I can't find a way to make a feature work in all (most) browsers then I drop the feature. Less headaches that way. Also, validating as xhtml seems like a great place to start for browser friendly code.

ua  = Request.ServerVariables("HTTP_USER_AGENT")
If Instr(ua, "MSIE") Then
   AnyIE = True
   If Instr(ua, "MSIE 6.") Then
           IE6 = True
   ElseIf Instr(ua, "MSIE 5.") Then
      IE5 = True
   ElseIf Instr(ua, "MSIE 4.") Then
      IE4 = True
   ElseIf Instr(ua, "MSIE 3.") Then
      IE3 = True
      If Instr(ua, "MSIE 3.02") Then
         IE302 = True
      End If
   End If
ElseIf Instr(ua, "Mozilla") or Instr(ua, "Gecko") And Instr(ua, "compatible") = 0 Then
   AnyNetscape = True
   if Instr(ua, "Gecko") then
         Netscape6 = True
   end if
   If Instr(ua, "Mozilla/4") Then
      Netscape4 = True
   ElseIf Instr(ua, "Mozilla/3") Then
      Netscape3 = True
   End If
End If

if not IE3 and not IE302 and not Netscape3 then
   'css probably available
end if


0
 
rouxjeanAuthor Commented:
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) ?
0
 
chisholmdCommented:
Where is your audience? North America? Europe? Elseware?  

http://www.utoronto.ca/ian/books/xhtml2/exerpt/css-4a.html
0
 
chisholmdCommented:
Why do you need to detect support for CSS? And why do you think there might still be visitors using old browsers?
0
 
rouxjeanAuthor Commented:
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.
0
 
chisholmdCommented:
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.



0
 
rouxjeanAuthor Commented:
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) :
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_21225151.html
So for resume, it is not possible using ASP right ? (besides getting browser name and comparing it to a CSS compatible Browser list)
0
 
davidlars99Commented:
this is best you can get for FREE...!!!

1. It checks if javascript is enabled, if not goes to "noscript.html"
2. once page is loaded and there is no CSS support it changes with "nocss.html"


<noscript>
<meta HTTP-EQUIV=refresh CONTENT=0;url=noscript.html>
</noscript>
<html>
<head>
<script language=Javascript>

function CSS(){
    if (!document.styleSheets)
          location.href="nocss.html";
}

</script>
</head>
<body onload=CSS()>
....
....
....

</body>
</html>


P.S.  I  would not worry about visitors who don't have CSS supported (it's not that complicated to guess) web browser and please don't ask me why...  :)
0
 
chisholmdCommented:
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.



0
 
rouxjeanAuthor Commented:
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.
0
 
chisholmdCommented:
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?



0
 
hongjunCommented:
@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.
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20745677.html


hongjun
0
 
rouxjeanAuthor Commented:
@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...
0
 
rouxjeanAuthor Commented:
That's false advertising then :-)
Thanks
0
 
chisholmdCommented:
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,


0
 
davidlars99Commented:
I don't think so...   :)
0
 
chisholmdCommented:
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
0
 
davidlars99Commented:
you were holding your breath since you've posted that comment, you're really good...
0
 
chisholmdCommented:
:) lol, well I'm alergic to lawsuites

0
 
hongjunCommented:
>>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
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 9
  • 8
  • 4
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now