PDA

View Full Version : Detecting browser with Microsoft Browser Capabilities Component


simplyblue
09-27-2002, 09:41 AM
Hi,
I'm trying to detect the browser of a user with the following code:

set browObj = Server.CreateObject("MSWC.BrowserType")
response.write "Browser is: " & browObj.browser & " ver " & browObj.version

But the result displays 'Netscape ver 4.00' when i'm using a IE 6!

Is there something wrong with the codes?

Another question, can I also detect the OS, and also if it's a PDA browser?

Thanks!

Mhtml
09-27-2002, 11:05 AM
Nothing wrong with the code, it is just extremely unreliable.

Myself and Whammy tried to find a good way of detecting browsers but in the end Whammy made a script which was extremly good but couldn't detect the browser type all the time.

It is just not possible to get an accurate result all the time.

whammy
09-28-2002, 12:58 AM
Yup... in the end I gave up! Your best bet (I think) is to just get the HTTP_USER_AGENT and live with it... if you really need to report on it, you can do:

SELECT DISTINCT(user_agent) FROM table_name

to get all of the different user agents...

AND/OR

SELECT COUNT(DISTINCT(user_agent)) AS agent_count FROM table_name

to get the counts of each... and do a report on that - at any rate, that seems to be the easiest solution to me... if you do a search on google, there are a couple of companies that have extended the capabilities of Server.CreateObject("MSWC.BrowserType") with a third-party .dll file, but they still are not close to complete from the documentation I have read - although to be honest I gave up before trying those (especially since one company wanted you to buy the .dll).

:(

P.S. If you find a better way to do this, please let us know! I spent enough time researching it, that I think it's a waste of time.

You might want to read this post:

http://www.codingforums.com/showthread.php?s=&threadid=6586

As I edited my first post in that thread to share my conclusions, for whatever they are worth... and I'm far from perfect, so I could be very wrong! :)

aCcodeMonkey
09-28-2002, 01:49 AM
All,


You can use the serverVariable "http_user_agent" to retrieve the browser info

Example:
<%
dim sBrowserName
sBrowserName = Request.serverVariables("http_user_agent")
Response.Write sBrowserName
%>

Output:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Hotbar 4.1.2.0)

Much more reliable than browscap.ini

Hope this helps.. :cool:

simplyblue
09-28-2002, 04:51 AM
Thanks all!

Guess i can give up on the broswer capabilities. seems that it isn't capable at all yah.. :p

Can I use http_user_agent to detect different OS?

If not, sigh.. Do I really have to use Javascript??

whammy
09-28-2002, 05:31 PM
Unfortunately, javascript's output in this regard is also very unreliable. :(