[thelist] RE: thelist digest, Vol 1 #1814 - 27 msgs

Chris Blessing webguy at mail.rit.edu
Mon Nov 26 14:12:39 CST 2001


Paul-

You can parse lots of information out of the user agent string.  Here's a
snippet I just tested, seems to work (I tested across IE6, NS4.7, NS6.2):

<!-- begin wide window time ;) -->

<%
dim userAgent
userAgent = Request.ServerVariables("HTTP_USER_AGENT")

if instr(userAgent, "MSIE") then
	Response.Write "Using IE I see"
else
	' split the user agent string by "/"
	version = split(userAgent, "/")

	' this prints the first version number (5.0 NS6, actual browser version for
NS4x)
	'Response.Write "Using Mozilla version " & left(version(1), 4) & " ("

	' this is the real browser version # (for NS6 only)
	'Response.Write version(ubound(version)) & ")"

	' if the upper bound is numeric (i.e. the split produced a numeric val for
	' the last element of the array) then we are using NS6
	if isnumeric(version(ubound(version))) then
		if version(ubound(version)) >= 6 then
			' you can add else... statements below to catch forthcoming NS7 browsers
(laugh)
			Response.Write "Using NS6+ I see"
		' else ...
			' ...
		end if
	else
		' this catches all other NS browsers, not just 4.x
		Response.Write "Using NS4x or lower I see"
	end if
end if
%>

<!-- end wide window time -->

Email me if you want any info about the specifics of this code.  Of course
you also have the option of using JS to do browser detection, but this works
too.

-Chris


>
> Message: 4
> From: "Paul Backhouse" <paul.backhouse at 2cs.com>
> To: <thelist at lists.evolt.org>
> Date: Mon, 26 Nov 2001 13:40:43 -0000
> charset="iso-8859-1"
> Subject: [thelist] Detection Between IE and NS 6./6.0
> Reply-To: thelist at lists.evolt.org
>
> Hi peeps,
>
> doing a site at the moment and i need to use ASP to detect for NS 6/6.0.
>
> Currently using this code for IE and NS (4.x) detection - but i
> now need to
> be more specific as NS 4.x and NS 6.x are behaving differently on a width.
>
> userAgent = Request.ServerVariables( "HTTP_USER_AGENT" )
> IF INSTR( userAgent, "MSIE" ) > 0 THEN
> IEWidth = ""
> Else
> NSWidth = ""
> End If
>
> Does anyone know how i can find out if it Ns 6.x and show a
> different width?
>
> Cheers
>
> paul
>






More information about the thelist mailing list