Jump to content

Archived

This topic is now archived and is closed to further replies.

jwwceo

Browser detection

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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]  ;)

Share this post


Link to post
Share on other sites
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 simple

if ( $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

Share this post


Link to post
Share on other sites
Well, if you want to do it with php, here you go:

[code]<?php
echo $_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]

Share this post


Link to post
Share on other sites
simply use php to check for the user agent, it's pretty accurate, accurate enough for what you are trying to do.

Share this post


Link to post
Share on other sites
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 {


}

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.