jwwceo Posted September 13, 2006 Share Posted September 13, 2006 What's the best way to do browser detection?All I need it for is to see if a user is using FireFox. I have some javascript menus on my page and they are positioned absolute on my page. Firefox displays them a little bit off, like 10 pixels off, from where they are supposed to be. So I am hoping to detect Firefox and the output slightly different coordinates.Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/20675-browser-detection/ Share on other sites More sharing options...
Gruzin Posted September 13, 2006 Share Posted September 13, 2006 Try Google: [url=http://www.google.com/search?hl=en&q=browser+detection+javascript]http://www.google.com/search?hl=en&q=browser+detection+javascript[/url] ;) Quote Link to comment https://forums.phpfreaks.com/topic/20675-browser-detection/#findComment-91426 Share on other sites More sharing options...
jwwceo Posted September 13, 2006 Author Share Posted September 13, 2006 My javascript is written by a php program...so I was really more just looking for the best way to do this in pHP...and then write up a super simpleif ( $browser == Firefox){echo "this";}else {echo "something else";}but I'm don't know which browser detection is the most reliable??? or how to handle the myriad of responses I may get from diferrent versions. Is there a simple one that just detects the browser name, like Firefox?James Quote Link to comment https://forums.phpfreaks.com/topic/20675-browser-detection/#findComment-91435 Share on other sites More sharing options...
Gruzin Posted September 13, 2006 Share Posted September 13, 2006 Well, if you want to do it with php, here you go:[code]<?phpecho $_SERVER['HTTP_USER_AGENT'] . "\n\n";$browser = get_browser(null, true);print_r($browser);?> [/code]For more info try manual: [url=http://ge.php.net/get_browser]http://ge.php.net/get_browser[/url] Quote Link to comment https://forums.phpfreaks.com/topic/20675-browser-detection/#findComment-91438 Share on other sites More sharing options...
Ninjakreborn Posted September 13, 2006 Share Posted September 13, 2006 simply use php to check for the user agent, it's pretty accurate, accurate enough for what you are trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/20675-browser-detection/#findComment-91440 Share on other sites More sharing options...
jwwceo Posted September 14, 2006 Author Share Posted September 14, 2006 I'm trying this. but it doesn't recongize work. Everything is going to the else...IE and Firefox... IS there a simpler script I could use instead....if (!(strpos($HTTP_USER_AGENT,'Mozilla') === false)) {}else {} Quote Link to comment https://forums.phpfreaks.com/topic/20675-browser-detection/#findComment-91459 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.