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 %> |