Diana Castillo wrote:
 > What is the code to tell whether the user is on IE or Netscape?

It's slightly more complicated than that (I'm a newbie too, but I know a
very little about user-agent strings), but it *will* involve using
http://www.php.net/manual/en/function.get-browser.php

As you may be aware, IE's user-agent string was originally designed to
look as similar to Netscape's as possible to avoid the idiots who block
non-Netscape users[0], but there are some differences.

Usually checking for "MSIE" in the string is enough.  Here's a sample IE 
string:

   Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Hotbar 2.0)

This tells us it's IE6, running on Windows '98, and the user has Hotbar 
installed.

And here's a sample Netscape Navigator 4:

   Mozilla/4.5 [en] (Win98; I)

This tells us it's Navigator 4.5, looking for english pages, running on 
Windows '98.  Anyone who tells me what the "I" stands for wins 3 cool 
points.

Of course, sometimes browsers (like Konqueror, or Opera) are set up to 
spoof IE or Netscape, for the same reason IE was given the "Mozilla/4.0" 
string in the first place.  In the case of Konqueror, the entire 
UA-string is configurable by the user, but for Opera, the browser's name 
is always included somewhere.  Here's one for Opera:

   Mozilla/4.0 (compatible; MSIE 5.0; Linux 2.4.2-2 i686) Opera 5.0  [en]

This tells us it's Opera 5, looking for english pages, running on Linux 
(kernel 2.4.2, Intel), and pretending to be IE5.

It's easy to work out what a browser's user-agent string is.  What's 
/not/ easy is telling a computer to work out what *browser* it is.

You can just do a simple search for "MSIE" in the string, which will 
prevent you from blocking out spoofers[1] from your script and give you 
less accuracy, but would also provide relatively little work and 
successfully separate Netscape from IE-and-spoofers :o).

One thing to remember: there's more than just Netscape out there. 
There's Mozilla, there's Opera, there's Dillo, there's Lynx, there's 
Links, there's Konqueror, there may even be a few poor fools stuck on 
Mosaic or Cello.  And what if someone has no browser, and just uses wget 
and their favourite text viewer?



[0] Oh, the irony!  Look at what clueless "designers" are doing to block
     non-IE users today :o)
[1] But then, I doubt you'd want to do that anyway... right?

-- 
Mark Gallagher
http://cyberfuddle.com/infinitebabble/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to