Click to See Complete Forum and Search --> : Ultimate sniffer
Motabobo
06-16-2003, 09:01 AM
Hi !
I would like to know if there is an equivalent in ASP for the
Ultimate Browser Sniffer (http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html) written in JavaScript ?
I've seen some components like BrowserHawk but they requires a registered dll and i don't want that. Is there any other free option without any OCX or DLLs ???
I'd like a script that can get the more info as possible about the user's browser (not just the vendor and version, javascript version, cookie,dhtml support,etc...
Here is an example of what BrowserHawk can do:
Test page (http://www.cyscape.com/showbrow.asp)
Here is the best script i found so far:
Code page (http://www.w3schools.com/asp/asp_browser.asp)
I'm sure you will agree that there is a tremendous difference in the amount of information given between the 2 scripts. For example, BrowserHawk is able to retrieve the screen info, dhtml support, cookie, etc...(are they using javascript ???!!!)
Anyone could help providing a link and/or an "all-in-one" script ?
Thanks !
Ribeyed
06-16-2003, 04:05 PM
Hi,
looked at the example you gave and i think you can retrieve about 60% of the ones BrowserHawk lists using ASP. About another 10% can possibly be workout.
I looked through BrowserHawk and was interested in the ASP.NET to see if any more can be retrieve than through classic ASP using the HTTPHeader. BrowserHawk had a few versions JAVA and ASP.NET were the 2 that stuck in my mind. I then had a look for the ASP.NET equlviant of the ASP HTTPHeader is and found this information on the microsoft support pages:
http://support.microsoft.com/default.aspx?scid=kb;en-us;311281
and this:
http://support.microsoft.com/default.aspx?scid=kb;en-us;306576
now i know this will not give you all the answer but i don't think its just as easy as give you a script to do this.
I think you would need to decide which server-side language you are going to use then look for answers for that technology. I also think you will not be able to achieve this with JavaScript.
Motabobo
06-16-2003, 04:26 PM
So if i understand right, all the work must be done by either the BrowserType object of the ServerVariables (or both).
So there is no extra tricks ???? Both articles used the same techniques as the script i posted earlier and there is no documentation about some information that BrowserHawk is able to get :
detect the screen width, dhtml, mouseover (how the hell ?) detection !!!
I agree that ServerVariables can give me a lot of things but if I reformulate my question to : how to detect the screen width & height using ASP ???
There must be a technique to detect some client side parameters ?!?!
Ribeyed
06-16-2003, 04:55 PM
Hi,
ok, some of these you can retrieve client side like Browser type, screen width and check for particular plugins, others you need server-side such as DHTML, frames, tables and JavaApplets.
From within ASP you can use the following code to display all the browser details:
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<%
for Each key in request.ServerVariables
response.write "<tr><td>" & key & "</td><td>" & request.servervariables(key) & "</td></tr>"
next
%>
<TR><TD><% FullReferer = Request.ServerVariables("http_referer")%>Refferer</TD><TD><%=FullReferer%></TD></TR>
</table>
or something like this to retrieve and write to variables:
set BC = server.createobject("MSWC.BrowserType")
IPAddress = Request.ServerVariables("remote_addr")
UserAgent = Request.Servervariables ("HTTP_USER_AGENT")
Browser = BC.Browser & " " & BC.Version
DHTMLSupport = cstr(BC.dhtml)
FramesSupport = cstr(BC.frames)
TablesSupport = cstr(BC.tables)
CookiesSupport = cstr(BC.cookies)
BackGroundSounds = cstr(BC.backgroundsounds)
JavaScriptSupport = cstr(BC.javascript)
JaveAppletsSupport = cstr(BC.javaapplets)
ActiveXControlsSupport = cstr(BC.activexcontrols)
AOL = cstr(BC.aol)
Platform = cstr(BC.platform)
VBScriptSupport = cstr(BC.vbscript)
FullReferer = Request.ServerVariables("http_referer")
if len(FullReferer) <= 7 then
RefererDomain = "-"
RefererQuery = "-"
else
SlashPosition = instr(8, FullReferer, "/")
if SlashPosition = 0 then
RefererDomain = FullReferer
RefererQuery = "-"
else
RefererDomain = left(FullReferer, SlashPosition - 1)
RefererQuery = right(FullReferer, len(FullReferer) - SlashPosition)
end if
end if
All this is retrieved by ASP from the browsercap.ini file. Without trying to write a script for to retrieve all the same ones as browserhawk i couldn't be completly sure if i could do it in just ASP alone. I would need some ASP and some JavaScript, again not sure if this would give me enough to equal BrowserHawk.
So i think you are still looking at either Java or ASP.NET for this.
Motabobo
06-16-2003, 05:32 PM
Thanks for you help :-)
DHTML detection doesn't work...
I've searched on msdn and i don't think we can't get anything else with the BrowserType object, right ??
As for the screen width & height, do you have any idea ?
Ribeyed
06-16-2003, 05:52 PM
Hi,
I see what you are saying about DHTML all 50,000 records in my works database has the DHTML field value as unknown. Now this maybe a question for the DHTML forum, can you just asume based on the Brower type detected with the Browser = BC.Browser & BC.Version that is a particular browser is found then it supports DHTML and if another type is detected then it is not. Apart from that in regard to the DHTML maybe better luck with Java or ASP.NET. Maybe someone else here can answer why the DHTML (BC.dhtml) is returning unknown.
On the screen size and width question thats javscript and would be better answer in that forum, i ain't a javascript coder. However you need to ask for the correct syntax for the getting screen.width and screen.height or screen.availheight and screen.availwidth.
Hope this helps
Motabobo
06-16-2003, 07:45 PM
Ok so there is no way to detect screen size with ASP ?
BrowserHawk is doing false advertising then lol
Many thanks for your help !
Ribeyed
06-19-2003, 01:27 PM
Hi,
found an answer to ASP detecting screen size, apparently ASP can detect screen height and width using the ClientCaps Behavior. There are a few more browser details you detecting using ClientCaps.
availHeight
availWidth
bufferDepth
colorDepth
cookieEnabled
cpuClass
height
width
javaEnabled
platform
systemLanguage
userLanguage
Looking at the code i have is seems to be for IE only
here is some code for doing this:
<HTML XMLNS:IE>
<HEAD>
<STYLE>
IE\:clientCaps {behavior:url(#default#clientCaps)}
</STYLE>
</HEAD>
<BODY>
<IE:clientCaps ID="oClientCaps" />
<SCRIPT LANGUAGE = VBScript>
Sub window_onLoad()
sCookieStr = "availHeight=" & oClientCaps.availHeight
Document.Cookie = sCookieStr
sCookieStr = "availWidth=" & oClientCaps.availWidth
Document.Cookie = sCookieStr
sCookieStr = "bufferDepth=" & oClientCaps.bufferDepth
Document.Cookie = sCookieStr
sCookieStr = "colorDepth=" & oClientCaps.colorDepth
Document.Cookie = sCookieStr
sCookieStr = "cookieEnabled=" & oClientCaps.cookieEnabled
Document.Cookie = sCookieStr
sCookieStr = "cpuClass=" & oClientCaps.cpuClass
Document.Cookie = sCookieStr
'etc....
End Sub
</SCRIPT>
</BODY>
</HTML>
hope this helps
Motabobo
06-19-2003, 01:50 PM
Thanks :D
Where the heck did you find this ???
That code you gave doesn't write any output on my machine.
Ribeyed
06-19-2003, 02:07 PM
Hi,
The script i gave you leaves a number of cookies on the client computer. Each cookie corresponds to one of the browser capaabilites. If you send this script to the client as part of the main page or another page , these cookies will be created on thier computer. BEcause the cookies have no expiration date, they're not saved on the client computer. They are per-session cookies and they expire at the end of the current session.
To access the calue of the cookie with the additional browser properties, you can read the values of the cookies from within any script.
example:
ClientCookies = Request.Cookies("cookiesEnabled")
BrowserWidth = request.cookies("Width")
If Not ClientCookies Then
Response.write "we have detected that you have disabled cookies."
else
response.Cookies("LastVisit") = now()
End If
If BrowserWidth < 1000 then
'show a low resolution page.
else
'show a high resolution page
end if
Motabobo
06-19-2003, 03:30 PM
What a dumb ass i am !
Ok, everything is cool :D
I found the msdn article (http://msdn.microsoft.com/library/default.asp?url=/workshop/author/behaviors/reference/behaviors/clientcaps.asp) talking about it. Really works great.
Anyway, as you mentionned it won't work for Netscape but is there any workaround for this ???? or another method ?
Thanks !
Ribeyed
06-20-2003, 03:46 PM
hi,
Anyway, as you mentionned it won't work for Netscape but is there any workaround for this ???? or another method ?
Not sure, i am one of these really bad developers who doesn't care about Netscape.:)