|
-
Feb 2nd, 2002, 02:28 PM
#1
Thread Starter
Member
Getting Browser and OS names & versions from user
I am working on a tracking system and am having a little trouble getting the users Browser version and the OS name and version.
I have tried via JavaScript and ASP and both ways have flaws.
In JavaScript I tried:
Code:
an=navigator.appName;
av=navigator.appversion;
at=navigator.useragent;
an will return Netscape or Microsoft Internet Explorer (dont care about others yet) but av and at will only return "Undefined"... and untill I can get something other than what I am getting I cant find out how to get the OS.
In ASP I tried:
Code:
if instr(request.servervariables("HTTP_USER_AGENT"), "MSIE") then
tempArr = split(request.servervariables("HTTP_USER_AGENT"), ";", -1,1)
response.write "browser: " & temparr(1) & "<BR>"
response.write "os: " & temparr(2) & "<BR>"
elseif instr(request.servervariables("HTTP_USER_AGENT"), "4.78") then
tempArr = split(request.servervariables("HTTP_USER_AGENT"), ";", -1,1)
response.write "browser: Netscape<BR>"
tempArr = split(request.servervariables("HTTP_USER_AGENT"), "(", -1,1)
tempArr2 = split(temparr(1), ";", -1,1)
response.write "os: " & temparr2(0) & "<BR>"
end if
That will work as far as getting the IE browser & version easy but NS is alot more work (as with everything else to do with netscrap) but the getting the os is more tricky cos WinME will show as Win98 but has an extra string... and while I could all tons of code to pick out all these things I am thinking there must be a cut and dry way to do this... or someone has done it before and there is code posted somewhere... I mean, why try to reinvent the wheel when there are porches already on the road?
thanks in advance,
Michael
-
Feb 3rd, 2002, 12:07 PM
#2
Member
Hi,
If you go to the netscape site, there is a "Ultimate Browser Sniffer" (or somesuch) script. It has code for everything you want.
As an example:
var agt=navigator.userAgent.toLowerCase();
var isMajor = parseInt(navigator.appVersion);
var isIE = (agt.indexOf("msie") != -1);
var isIE4 = (isIE && (isMajor == 4) && (agt.indexOf("msie 5.0")==-1) );
var isIE4up = (isIE && (isMajor >= 4));
var isAOL = (agt.indexOf("aol") != -1);
Vinny
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|