penders

msg:4220579 | 7:37 pm on Oct 22, 2010 (gmt 0) |
That long string is simply the "user agent" string that the browser sends to identify itself. You don't need a lengthy script to get the user agent, it's just one line of code. eg. in PHP, $_SERVER['HTTP_USER_AGENT'] or in JavaScript, navigator.userAgent. In order to get something like "Safari 5" you can write a script to intelligently parse the user agent for the appropriate parts you are looking for. This will work OK for the main browsers. If you need to dig deeper and try to identify all browsers / robots / crawlers then you probably need to look up the user agent in some kind of database.
|
floydboy

msg:4221368 | 8:09 pm on Oct 24, 2010 (gmt 0) |
I'm a novice, I don't know how to parse out that info to show... how would I do that?
|
penders

msg:4221485 | 8:14 am on Oct 25, 2010 (gmt 0) |
Depending on the language of choice, you're perhaps better asking this in the appropriate forum... eg. JavaScript (client-side in the browser): [webmasterworld.com...] PHP (Server-side) [webmasterworld.com...]
|
milosevic

msg:4221577 | 12:32 pm on Oct 25, 2010 (gmt 0) |
In pseudo-code: if ($user-agent == 'some long string of crap #1') { $user-agent = 'Safari 5'; } elseif ($user-agent == 'some long string of crap #2') { $user-agent = 'IE 6'; } A smart programmer would use an associative array or at least a switch statement though.
|
|