| the complete webmaster | ||||
| tutorials | reviews | reference | ||
|
...and the Browser Wars ContinueAs you know, a lot of attention is being given to the battle for the world's most popular web browser. Hopefully, many browsers will continue to be available, thus giving users a wide range of choices. Everyone has distinct tastes, and one company's browser cannot be right for every user in the world. Everyone, however, wonders how popular certain browsers are. If you look through your web server's logs, you'll find that the "HTTP_USER_AGENT" gives you a hint as to which browser is being used. Values for USER_AGENT look something like the following:
Trying to figure out what type of browser is being used can be a complex task. Trying to keep score of which browser is most popular adds another level of complexity to the problem. This week's script provides a simple way to track and display how the browser battle is faring on a web page near you. First, to reduce complexity of the script, only four distinct USER_AGENTs are detected:
Also, it's important to know about proxies. A proxy is a special piece of software that sits between a user's machine and your web server. The user connects to the proxy, then the proxy connects to your web server. User --> Proxy --> Web Server The proxy may change the USER_AGENT variable or it may leave it alone. Because many users use one proxy and each proxy has one IP address, the script will undercount the number of users. To use this script, you'll need to enable Server Side Includes in your web server. To learn about Server Side Includes (SSI) in Apache, check out these references: Next, you'll need to obtain the Perl script: Save the perl script to a safe place. Next, make the script executable:
# path and name for the access log Change path and name to point to where you want to store the data file. After selecting a suitable location, issue the following commands to make sure the file can be read and written by your web server daemon:
Next, after enabling SSI, add the following code to an HTML file: <!--#exec cmd="/path/whatbrowser.pl"--> Change the /path to point to the directory where you stored the script. With luck, you should have something like the following on your web page:
Every time someone looks at the page, the results will be updated. Now, you'll always know how the battle for the most popular web browser is going on your web site. Note: This program has been tested on many flavors of Unix running the Apache web server. It may not, however, work correctly on all web servers, especially non-Unix ones.
Author: Doug Steinwand
Date: [12/09/97]
More articles about CGI
More articles by Doug Steinwand Author Biography |
| write for us | about us | advertise |
Copyright 1997, 1998 A Big Lime. All rights reserved.