[thelist] Re: Browser Detection

Ryan Finley RyanF at SonicFoundry.com
Fri Feb 23 13:59:46 CST 2001


The best browser detection tool I've found under ASP is BrowserHawk
(http://www.browserhawk.com/)

The coolest feature is the ability to select browsers by FEATURE rather than
trying to figure out which browser supports what.

And they have an automatic update feature to keep their browser definition
files up to date.

	Ryan Finley
	President - SurveyMonkey.com


-----Original Message-----
From: Andre Gaulin [mailto:gaulin at mac.com]
Sent: Friday, February 23, 2001 12:56 PM
To: thelist at lists.evolt.org
Subject: Re: [thelist] Re: Browser Detection


hey everyone...

i know this whole browser detection thread started with a request for a
javascript detection scheme, but i wrote this one in ASP a while ago and i
have found it to be pretty solid.  it is great for detecting and customizing
CSS and other browser specific stuff, even WAP stuff.  any comments on it,
or suggestions to improve it are more than welcome..

CODE IS BELOW...

andre

<!-- WML DETECTION FIRST -->
<%
Dim sBOTBrowser
sBOTBrowser = Request.ServerVariables("HTTP_USER_AGENT")
sBOTBrowser2 = Request.ServerVariables("HTTP_ACCEPT")
if Left(sBOTBrowser, 4) = "UP.B" or _
   Left(sBOTBrowser, 4) = "Noki" or _
   Left(sBOTBrowser, 4) = "Eric" or _
   Instr(sBOTBrowser2, "wml") <> 0 then %>
<!-- WML INCLUDE HERE -->

<!-- WINDOWS -->
<%Elseif InStr(sBOTBrowser, "Win") >0 Then
Select Case True
 Case InStr(sBOTBrowser, "MSIE") >0 AND InStr(sBOTBrowser, "Mozilla/3.") >0
%>
<!-- IE 3 stuff --> <p>IE3 WIN</p>
<% Case InStr(sBOTBrowser, "MSIE") >0 AND InStr(sBOTBrowser, "Mozilla/4.")
>0 %>
<!-- IE 4+ stuff --> <p>IE4+ WIN</p>
<% Case InStr(sBOTBrowser, "Mozilla/3.") >0 %>
<!-- NETSCAPE 3 STUFF --><p>NETSCAPE 3 WIN </p>
<% Case InStr(sBOTBrowser, "Mozilla/4.") >0 %>
<!-- NETSCAPE 4 STUFF --><p>NETSCAPE 4 WIN </p>
<% Case InStr(sBOTBrowser, "Mozilla/5.") >0 %>
<!-- NETSCAPE 5 STUFF - MAY BE IRRELEVANT AND CAN GO WITH
MSIE --><p>NETSCAPE 5 WIN </p>
<% Case Else %>
<!-- ALL OTHER STUFF - OPERA, ETC> --><p>OTHER STUFF PC</p>
<% End Select %>

<!-- MAC DETECTION -->
<%Elseif InStr(sBOTBrowser, "Mac") >0 Then
Select Case True
 Case InStr(sBOTBrowser, "MSIE 4.5") >0 %>
<!-- IE 4.5+ stuff --><p>IE 4.5+ MAC</p>
<% Case InStr(sBOTBrowser, "MSIE 5.0") >0 %>
<!-- IE 5+ stuff --><p>IE 5+ MAC</p>
<% Case InStr(sBOTBrowser, "MSIE 5.5") >0 %>
<!-- IE 5+ stuff --><p>IE 5.5 MAC</p>
<% Case InStr(sBOTBrowser, "Mozilla/4.") %>
<!-- NETSCAPE 4+ stuff --><p>NETSCAPE 4+ MAC</p>
<% Case InStr(sBOTBrowser, "Mozilla/5.") >0 %>
<!-- NETSCAPE 5+ stuff --><p>NETSCAPE 5+ MAC</p>
<% Case Else %>
<!-- EVERYTHING ELSE - OPERA, OMNIWEB, ETC. --><p>OTHER STUFF MAC</p>
<% End Select%>

<!-- ANYTHING ELSE NON MAC OR WINDOWS OR WML -->
<%Else%>
<!-- LOW TECH/NON WIN-MAC INCLUDE HERE (typically netscape 3 compatible or a
redirect to PLEASE UPGRADE/NOT SUPPORTED --><p>OTHER STUFF NON-WIN-MAC</p>
<%End If%>



---------------------------------------
For unsubscribe and other options, including
the Tip Harvester and archive of TheList go to:
http://lists.evolt.org Workers of the Web, evolt ! 




More information about the thelist mailing list