Click to See Complete Forum and Search --> : Server side browser version detecting


richiebman
06-01-2004, 08:43 AM
Hello all.

Since I recently checked my websites in old versions of (hopefully nearly obsolete) popular browsers eg: Netscape 4.7, I found out they look cack. So I've decided to make text versions of my websites, so these users can view these instead of my perfectly valid W3C xhtml 1.0 and css 2.0 table free websites (I wish they would download the next available....FREE....versions).

So could someone point me in the right direction of some scripts that detect the browser version, and then redirects the user to the text version instead of the usual homepage.

I would prefer to do this on the server side, but will do it via Javascript if required.

Other suggestions on how to modify the same website so it displays asthetically in old browser versions, would also be appreciated.

Cheers,
R

buntine
06-01-2004, 09:26 AM
Server-side languages which support the ServerVariables collection can easily detect the browser used to request the page. Below are some examples which will return a string.

'ASP
Request.ServerVariables("HTTP_USER_AGENT")

//PHP
$HTTP_SERVER_VARS['HTTP_USER_AGENT']

//CGI
$ENV{"HTTP_USER_AGENT"}

richiebman
06-01-2004, 09:59 AM
Sounds good buntine, but as my scripting skills are fairly basic, I really would need more help in developing a script from this starting point. Do you know any online tutorials that can talk you through such a script. Would prefer to go along the PHP route?

Cheers,
R

buntine
06-01-2004, 11:35 AM
The following page contains some helpful PHP browser detection scripts.
http://tech.ratmachines.com/downloads/free_scripts.php

Also, this page may be helpful.
http://www.nic.fi/~tapio1/Nt/PHPEn3.php3

Regards,
Andrew Buntine.

Jeff Mott
06-01-2004, 01:10 PM
The best browser detection routines I have ever come across is at http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html

Though, this is in JavaScript. However, I believe the user agent string that JavaScript accesses is that same as what is sent to the server side program. So you could rewrite the JS routines into whatever language you want.

richiebman
06-01-2004, 01:46 PM
Cheers guys. Some interesting stuff there. Will come back if I'm stuck.
R