|
Browser Wars part 2
Now for part two where we will display the counts
as images and also some explanations about why we used some
of the methods and things to look for.
Code :
<%
'we are creating a subroutine which basically takes a textfile
as a parameter
'and displays the count as an image
Sub OpenFile(textfile)
'our variables
Dim objFSO , objTS , counter_file
'creat an instance of file system object
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'open the text file
Set objTS = objFSO.OpenTextFile(Server.MapPath(textfile))
'while file is not empty
Do While Not objTS.AtEndOfStream
'read the count and stor in count variable
count = objTS.ReadLine
'next line is for debugging to check the value of count
'Response.Write count
'display our count as an image
For i = 1 to Len(count)
Response.Write "<img src=""images/2/"
& Mid(count, i, 1) & ".gif" & """>"
Next
Loop
'close object and destroy objects
objTS.Close
Set objTS = Nothing
Set objFSO = Nothing
End Sub
%>
<%
'start creating our table for display purposes
Response.Write "<table><tr><th>Browser</th><th>Count</th></tr>"
%>
<%
Response.Write "<td>Internet Explorer</td><td>"
'call the OpenFile Sub with the internet explorer file
Call OpenFile("ie.txt")
Response.Write "</td><tr>"
%>
<%
Response.Write "<td>Netscape</td><td>"
'call the OpenFile Sub with the netscape file
Call OpenFile("netscape.txt")
Response.Write "</td></tr>"
%>
<%
Response.Write "<td>Others</td><td>"
'call the OpenFile Sub with the opera/others file
Call OpenFile("opera.txt")
%>
<%
'complete html tags
Response.Write "</td></tr></table>"
%>
Notes :
OK some things to go over here , people may ask
why did we not use the Browser capabilities object , well in
Internet Explorer 6 this returned that it was Netscape on our
system . Opera 5.12 displays itself as Netscape on our system
using this script .
|