To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > Misc Help > ClientSide Technologies

ClientSide Technologies Discuss HTML/CSS/Javascript, and any other client-side technologies, here.

Reply
 
Thread Tools Rate Thread Display Modes
Old 02-16-2006, 12:24 AM   #1
thread_PHP
Senior Member
 
thread_PHP's Avatar
 
Join Date: Jan 2006
Posts: 266
mozilla firefox problem

hi friends
how to recognize mozilla firefox browser do u know in javascript one of my application works in mozilla but not displaying properly with boxes in firefox


thanks in advance
thread_PHP is offline   Reply With Quote
Old 02-16-2006, 04:41 AM   #2
Weedpacket
Custom User Title™
 
Weedpacket's Avatar
 
Join Date: Aug 2002
Location: Rapid Offensive Unit "Foreign Object Damage"
Posts: 19,137
Look to see if the useragent contains the word "Firefox".

Kind of depends on how you're checking for Mozilla (apparently not through checking client capabilities, which is the best practice method).
__________________
On two occasions I have been asked [by Members of Parliament], "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
Weedpacket is offline   Reply With Quote
Old 02-16-2006, 05:20 AM   #3
thread_PHP
Senior Member
 
thread_PHP's Avatar
 
Join Date: Jan 2006
Posts: 266
hi
i am using browsertest.php like this
PHP Code:
function browser_detection( $which_test ) {

    $browser = '';
    $dom_browser = '';

    $navigator_user_agent = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? strtolower( $_SERVER['HTTP_USER_AGENT'] ) : '';
    
    
    if (stristr($navigator_user_agent, "opera"))
    {
        $browser = 'opera';
        $dom_browser = true;
    }

    elseif (stristr($navigator_user_agent, "msie 4"))
    {
        $browser = 'msie4';
        $dom_browser = false;
    }

    elseif (stristr($navigator_user_agent, "msie"))
    {
        $browser = 'msie';
        $dom_browser = true;
    }

    elseif ((stristr($navigator_user_agent, "konqueror")) || (stristr($navigator_user_agent, "safari")))
    {
        $browser = 'safari';
        $dom_browser = true;
    }

    elseif (stristr($navigator_user_agent, "gecko"))
    {
        $browser = 'mozilla';
        $dom_browser = true;
    }
    
    elseif (stristr($navigator_user_agent, "mozilla/4"))
    {
        $browser = 'ns4';
        $dom_browser = false;
    }
    
    else
    {
        $dom_browser = false;
        $browser = false;
    }

    if ( $which_test == 'browser' )
    {
        return $browser;
    }
    elseif ( $which_test == 'dom' )
    {
        return $dom_browser;
    }
}




$user_browser = browser_detection('browser');

function browser_detection1( $which_test ) {

        $browser = '';
    $dom_browser = '';

    
    $navigator_user_agent = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? strtolower( $_SERVER['HTTP_USER_AGENT'] ) : '';
    
        
    if (stristr($navigator_user_agent, " windows nt 5.0"))
    {
        $browser = 'windows nt 5.0';
        $dom_browser = true;
    }

    elseif (stristr($navigator_user_agent, "msie 4"))
    {
        $browser = 'msie4';
        $dom_browser = false;
    }

    elseif (stristr($navigator_user_agent, "msie"))
    {
        $browser = 'msie';
        $dom_browser = true;
    }

    elseif ((stristr($navigator_user_agent, "konqueror")) || (stristr($navigator_user_agent, "safari")))
    {
        $browser = 'safari';
        $dom_browser = true;
    }

    elseif (stristr($navigator_user_agent, "gecko"))
    {
        $browser = 'mozilla';
        $dom_browser = true;
    }
    
    elseif (stristr($navigator_user_agent, "mozilla/4"))
    {
        $browser = 'ns4';
        $dom_browser = false;
    }
    else
    {
        $dom_browser = false;
        $browser = false;
    }

    if ( $which_test == 'os' )
    {
        return $browser;
    }
    elseif ( $which_test == 'dom' )
    {
        return $dom_browser;
    }
}
$user_os = browser_detection1('os');

calling.php i am using like this

<?php if ( $user_browser == 'mozilla' )
        {
    
?>
thread_PHP is offline   Reply With Quote
Old 02-16-2006, 09:48 AM   #4
MarkR
Senior Member
 
Join Date: Jul 2004
Location: Oxford, England
Posts: 1,983
Don't use browser detection - simply write your Javascript correctly in the first place.

Of course one reason you mustn't use browser detection is that sometimes it's ineffective (user agent blocked), or actually inaccurate (sometimes browsers lie).

But the main reason you mustn't use browser detection, is that that won't help people who use web browsers other than the ones you've tested it with (for example, ones which haven't been released yet).

If you absolutely MUST (for example, when handling events using MSIE's dodgy event model), then use feature-detection in the Javascript code. But most of the time, simply using the standard way of doing things (DOM1 etc) works well.

Mark
MarkR is offline   Reply With Quote
Old 02-16-2006, 10:36 AM   #5
thread_PHP
Senior Member
 
thread_PHP's Avatar
 
Join Date: Jan 2006
Posts: 266
Hi

Can you explain me in detail with any code
thread_PHP is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 06:54 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.