Forum Moderators: open

Message Too Old, No Replies

Logging you visitors stats

How to get the screen resolution using ASP - revealed

         

chris_f

9:55 am on Mar 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Guys and Gals,

I have built a visitor logging system. This gets all the stats you would normally get from logs and more. I logs and analyses all you visitors moves. I must say, even though it is my baby I am very impressed (please dont ask for a copy as I am not distributing it). However, there is a question that always crops up on many sites. I have decided to post an answer here in case anyone was struggling with this.

How, using ASP, do I obtain a visitors screen resolution?
This cannot be done using just ASP, however, it is possible. Here is a sample piece of code that uses client side script to pass the resolution to ASP so you can do what ever you want with it.

<%
Dim ScreenWidth
Dim ScreenHeight
If Request.QueryString("ScreenWidth") = " " Then
%>
<SCRIPT lauguage="VBScript">
Dim ScreenWidth
Dim ScreenHeight
ScreenWidth = Screen.Width
ScreenHeight = Screen.Height
document.location.href = "page.asp?ScreenWidth=" & ScreenWidth & "&ScreenHeight=" & ScreenHeight
</SCRIPT>
<%
Else
ScreenWidth = Request.QueryString("ScreenWidth")
ScreenHeight = Request.QueryString("ScreenHeight")
%>
<html>
<head>
</head>
<body>
Your resolution is <%= ScreenWidth %> x <%= ScreenHeight %>.
</body>
</html>
<%
End If
%>

Chris.

hakre

5:00 pm on Mar 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi chris_f,

nice post. i think it's better to use javascript in case the browser is not an ie one, isn't it?