in reply to Identifying browsers

A short search with Google brings me to this page, which tells me that most Netscape strings start with something like Mozilla/x.xxx(, and after that first opening parens, there is not the word compatible. This could be checked for with the following crummy code :

sub header_NS { # Assume that nobody uses Netscape anymore my $result = undef; # Get user agent passed as the only parameter my $user_agent = shift; if ($user_agent =~ m#^Mozilla/\d+#i) { # We have a Mozilla/NetScape compatible browser if ($user_agent !~ /compatible/i) { # And it's not even just "compatible", it's the real, # CSS burning, X crashing hellspawn $result = 1; }; }; return $result; };

The above code checks for any browser that claims to beo Mozilla, but also claims to be the real thing and not something compatible. But I think your idea of using User-Agent headers for this is flawed, as there are many instances where proxies change the user agent and there are also other browsers which have real problems with CSS support. I recommend you put a "This site without CSS" link into your script, which calls your script again with the parameter ?nocss=1 appended to the URL. This allows users with broken browsers to easily use your website even if your magic detection does not work because you didn't anticipate their specific browser.

Replies are listed 'Best First'.
Mozilla vs Netscape IDs
by khopesh (Initiate) on Aug 06, 2002 at 13:51 UTC
    your code will find all versions of Netscape, including fully CSS-compatible ones. for people looking for this solution in the NS6+/Mozilla era, add
    if ($user_agent !~ /gecko/i) {
    right before the
    $result = 1
    and match brackets as appropriate.

    I really hate it when a website decides my Mozilla 1.1b is not capable of rendering basic CSS (some sites won't even let me in).
Re: Re: Identifying browsers
by Melly (Chaplain) on Mar 30, 2001 at 18:51 UTC
    Thanks, good advice (I'd already planned to allow the option of disabling CSS, but it's nice to have it confirmed as a good idea)
    Tom Melly, tom@tomandlu.co.uk