Jump to content


Photo

Browser detection


  • Please log in to reply
5 replies to this topic

#1 jwwceo

jwwceo
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts

Posted 13 September 2006 - 11:08 PM

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!

#2 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 13 September 2006 - 11:14 PM

Try Google: http://www.google.co...tion javascript  ;)
I don't need your script, I'll try to write it myself

#3 jwwceo

jwwceo
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts

Posted 13 September 2006 - 11:30 PM

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

#4 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 13 September 2006 - 11:34 PM

Well, if you want to do it with php, here you go:

<?php
echo $_SERVER['HTTP_USER_AGENT'] . "\n\n";

$browser = get_browser(null, true);
print_r($browser);
?>

For more info try manual: http://ge.php.net/get_browser
I don't need your script, I'll try to write it myself

#5 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 13 September 2006 - 11:34 PM

simply use php to check for the user agent, it's pretty accurate, accurate enough for what you are trying to do.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#6 jwwceo

jwwceo
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts

Posted 14 September 2006 - 12:37 AM

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 {


}




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users