|
Browser Wars Part 1
An integral part of development for web sites
is browser support , it is a sad fact that nowadays neither
of the big two browsers adhere to the standards perfectly .
This script is a simple text based system where we detect a
users browser increment a count in a text file and then we will
eventually display the counts .
Create 3 text files with the number 0 in them
call the ie.txt , netscape.txt and opera.txt
Code :
<%
'declare our variables
Dim strUserAgent , objFSO , objTextStream , counter_file , count
'store the HTTP_USER_AGENT value in a variable
strUserAgent = Request.ServerVariables("HTTP_USER_AGENT")
'now we check for Internet explorer
If InStr(1 , strUserAgent , "MSIE") > 0 Then
counter_file = "ie.txt"
Else
'here we check for netscape
If InStr(1, strUserAgent , "Netscape") > 0 Then
counter_file = "netscape.txt"
Else
counter_file = "opera.txt"
End If
End If
'create an instance of the FileSystemObject
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'create an instance of TextStream object and open the relevant
text file
Set objTextStream = objFSO.OpenTextFile(Server.MapPath(counter_file))
'get the count
count = Clng(objTextStream.Readline)
'increment by 1
count = count + 1
'close
objTextStream.Close
'create the text file
Set objTextStream = objFSO.CreateTextFile(Server.MapPath(counter_file))
'write out the value of count in the relevant file
objTextStream.WriteLine(count)
'close and destroy objects
objTextStream.Close
Set objTextSTream = Nothing
Set objFSO = Nothing
%>
In the next part we will read all of the stored
counts and display them as images and explain a couple of quirks
we had when we were developing this idea.
Part 2 : displaying
the data
|