Page: Previous  1, 2

jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
No, not really, since you have to test for ns, msie etc no matter what, if you want it to say 'Microsoft Internet Explorer' or Netscape, remember that when it's id'ed as ns, it's not mozilla / firefox, it's the old netscape 2-4x series.

there is a separate routine to id the new mozilla series browsers, it's pretty complete.

Also note you can do it like this, make only 2 calls to the function:

:: Code ::

$browser = browser_detection( 'browser' );
$browser_number = browser_detection( 'number' );
if ( ( $browser == 'ie' )
&&
( browser_detection( 'number' ) >= 5 ) )
{
echo 'Internet Explorer ' .
$browser_number;
}
elseif ( ( $browser == 'ns' ) )
{
echo 'Netscape ' .
$browser_number;
}
elseif ( ( $browser != 'moz' )
{
// this will make first letter of browser string uppercase
echo ucfirst( $browser  ) .  ' ' .
$browser_number;
}
else do the moz stuff....


check the download for the computer information box on how to do the mozilla testing.

:: Quote ::
do you know a good way to test this for all these browsers without downloading them and installing them all?


We use mozilla firefox with the extension: 'use agent switcher', then we have about 30+ navigator user agents, add more as needed.
Back to top
guinness
Status: Interested
Joined: 05 Jul 2004
Posts: 12
Reply Quote
cool. that's a smart shortcut with upper-casing the first letter. thanks. i'll implement all the changes you suggested.

if you want to check out my implementation, visit:

22nd.org/detect/

i'm pretty happy thus far with the result.

-rob
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
That looks pretty nice, you will want to add the gecko/moz detection routine to that, currently it's not detecting firefox/mozilla at all.

The operating system version comes a line down from the operating system text.

By the way, made a major change on site, it's now techpatterns.com , update where appropriate. Just finished the major chunks of the site redo, we'll have to add a language detection page too.

If you get to the point where you have somewhere to put it, a link to our site would be cool.
Back to top
guinness
Status: Interested
Joined: 05 Jul 2004
Posts: 12
Reply Quote
yeah, i'll definitely link back to your site once i get to the point where i have a links page. in fact, i'm going to have a whole site about how my page was built, and i plan on mentioning you and what i learned from you on there.
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
Glad it's coming together for you. If you ever have any HTML/CSS type questions feel free to post them in the HTML/CSS forum.

In general, when you're testing any method or script, you should have at least the following browsers:

The new firefox browser, available at mozilla.org.

Opera

and a working copy of Netscape 4x, available for download from evolt.org, which by the way is a great place to find older browsers.

We test on a lot more than that, about 10 mozilla versions, 6 Opera versions, netscape 3-4, along with the new netscape releases 6-7x, which are id'ed by our browser detection script. Also smaller ones like Lynx etc.

But the big three should always be used, Opera, Mozilla/firefox, and Internet Explorer, version 6 if you have to pick one.
Back to top
guinness
Status: Interested
Joined: 05 Jul 2004
Posts: 12
Reply Quote
:: jeffd wrote ::
We test on a lot more than that, about 10 mozilla versions, 6 Opera versions, netscape 3-4, along with the new netscape releases 6-7x, which are id'ed by our browser detection script. Also smaller ones like Lynx etc.


Have you ever tried any of those browser-checkers that claim to test a bunch of browser versions all at once, or are those not very reliable? Seems like it would take a lot of time to check every page separately on a couple dozen different browsers.

I think I now have the mozilla test implemented correctly, but I'll post my code below, and maybe you can check it for mistakes. Also, is that extra line mistake fixed on the page. I think that was there because of an extra <p> tag.

:: Code ::
<?php
include('browser_detection.php');

$browser = browser_detection( 'browser' );
$browser_number = browser_detection( 'number' );
if ( ( $browser == 'ie' )
&&
( browser_detection( 'number' ) >= 5 ) )
{
echo 'Internet Explorer ' .
$browser_number;
}
elseif ( ( $browser == 'ns' ) )
{
echo 'Netscape ' .
$browser_number;
}
elseif ( ( $browser != 'moz' ) )
{
// this will make first letter of browser string uppercase
echo ucfirst( $browser  ) .  ' ' .
$browser_number;
}
elseif ($browser_info[0] == 'moz' )
         {
            $a_temp = $browser_info[count( $browser_info ) - 1];// the moz array is last item
            $full .= ($a_temp[0] != 'mozilla') ? 'Mozilla/ ' . ucfirst($a_temp[0]) . ' ' : ucfirst($a_temp[0]) . ' ';
            $full .= $a_temp[1] . '';
            $full .= 'ProductSub: ';
            $full .= ( $a_temp[4] != '' ) ? $a_temp[4] . '<br />' : 'Not Available';
            $full .= ($a_temp[0] != 'galeon')?'RV version: ' . $a_temp[3] : '';
         }
         else
         {
            $full .= ($browser_info[0] == 'ie') ? strtoupper($browser_info[7]) : ucwords($browser_info[7]);
            $full .= ' ' . $browser_info[1];
         }
         echo $full ;
         ?>

Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
:: Quote ::
Have you ever tried any of those browser-checkers that claim to test a bunch of browser versions all at once, or are those not very reliable? Seems like it would take a lot of time to check every page separately on a couple dozen different browsers.


Added comments in a new thread, which browsers to check website.

The code above won't work, you cut out the part where the mozilla information was loaded.

If you want a simple version, just use this:

:: Code ::
if ( $browser == 'moz' )
{
echo 'Mozilla ' . $browser_number;


This will print Mozilla + the rv version number, that's the gecko rendering engine version, not the actual browser version, in the case of mozilla it's the same version number, for most other gecko browsers it's different. In the above case, for example, a firefox 0.9 browser would be: Mozilla 1.7
Back to top
Display posts from previous:   
Page: Previous  1, 2
All times are GMT - 8 Hours