Detailed Server Side Browser Detection Script

Contributed by
Rating: 5 stars5 stars5 stars5 stars5 stars / 5
October 29, 1999
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

Detecting the browser type - on the server side




The article is some good code for detecting the browser type - on the server side. Itdelivers the right page while processing based on the browser type intsead of doing aredirect while the page is loading. It sends IE5 one way, IE4 another way, (or IE4& IE5 the same way), and everybody else another way. This is just one way ofcoding to really be detailed to which browser the user is using.

Here is the Code

<%@ Language=VBScript %>

<%
Dim sAgent,b_IE,b_Vers,b_Mac,b_Nav,b_Other
Dim ie4win,b_win,ie4,ie3,ie4mac,ns4

b_IE=false
b_Nav=false
b_Other = false
b_Vers = 0
sAgent = Request.ServerVariables("HTTP_USER_AGENT")

if (inStr(sAgent,"MSIE")>0) then
b_IE=true
b_Vers = Mid(sAgent,inStr(sAgent,"MSIE")+5,1)
elseif (inStr(sAgent,"MSPIE")>0) then
b_Vers = Mid(sAgent,inStr(sAgent,"MSPIE")+9,1)
else
b_Vers = Mid(sAgent,9,1)
end if

if (not (b_IE)) then
b_Nav=inStr(sAgent,"Mozilla")>0 or inStr(sAgent,"compatible")>0
end if

b_Win = (instr(sAgent,"Win")) > 0 'Windows
b_Mac = (instr(sAgent,"Mac")) > 0 'Mac
b_Other = not (b_Win or b_Mac) 'Other

ie4 = b_IE and b_Vers>=4 ' IE4
ie5 = b_IE and b_Vers>=5 ' IE5
ie3 = b_IE and b_Vers<4 ' Everything <IE4 we consider IE3
ie4Mac = b_Mac and ie4 ' IE4 Mac
ns4 = b_Vers>=4 and b_Nav ' NS4
ie4Win = b_Win and ie4 and not b_mac ' IE4 Windows
%>

<%

if ie5 then
' Send this File to IE5
response.write("simple1.htm")
elseif (ie4) then
' Send this File to IE4
response.write("simple2.htm")
else
' Send this File to other browsers
response.write("simple3.htm")
end if
%>

blog comments powered by Disqus
ASP CODE ARTICLES

- ASP Forms
- ASP: The Beginning
- Getting Remote Files With ASP Continued
- Inbox and Outbox Manipulation in ASP
- Relational DropDownList Using VB.NET
- Ad Tracking URL Hits
- Use ViewState to display one record per page...
- Send Email using ASP.NET formatted in HTML
- ASP File Explorer
- ASP/XML Interview questions by Srivatsan Sri...
- Pressing RETURN won't submit the form
- This shows how you get the TEXT of a combo r...
- Group Data by Adrian Forbes
- Multiple checkbox select sample
- Multiple checkbox select with all values sam...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials