Click to See Complete Forum and Search --> : mozilla firefox problem
thread_PHP
02-16-2006, 12:24 AM
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
Weedpacket
02-16-2006, 04:41 AM
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).
thread_PHP
02-16-2006, 05:20 AM
hi
i am using browsertest.php like this
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' )
{
?>
MarkR
02-16-2006, 09:48 AM
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
thread_PHP
02-16-2006, 10:36 AM
Hi
Can you explain me in detail with any code
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.