scriptygoddess

22 Jan, 2003

Proper testing for browser types

Posted by: amy In: Lessons learned

Since my site (domesticat.net) is skinned, I use PHP to test for a handful of browsers that require certain types of skins. In practice, this points lynx browsers to the lynx skin, and the PDA-type browsers to the ultralight skin.

Zalary (of everythingfalls.com) emailed me this morning to let me know that I'd made a goof, and that one of the text strings I was testing for now trips up under a Mac-based browser, Avant, that I'd never heard of before.

So, I thought I'd 1) pass along what I've found so far and 2) ask for any obvious browser strings I've missed.

Here's the code that I'm using now (insert usual disclaimers here about how this is PHP):

<?
if ((stristr($_SERVER['HTTP_USER_AGENT'],"palmos")) or
(stristr($_SERVER['HTTP_USER_AGENT'],"blazer")) or
(stristr($_SERVER['HTTP_USER_AGENT'],"wap")) or
(stristr($_SERVER['HTTP_USER_AGENT'],"avantgo"))) $skin = "13";

if (stristr($_SERVER['HTTP_USER_AGENT'],"lynx")) $skin = "3";
?>

(Everything between the 'if' and the ; is one line; if you're going to use this code, you'll need to take out those line breaks. I did it this way for easier reading.)

Short and sweet – if a case-insensitive check of the http_user_agent turns up matches against PalmOS, Blazer, WAP, or AvantGo, we're probably looking at a PDA user. (I previously tested for just 'Avant', and that's what tripped up Zalary's browser.)

Are there any common PDA browsers I've missed here? Since I don't do PDA-based browsing, I'm afraid I'm a little out of the loop on this issue.

7 Responses to "Proper testing for browser types"

1 | doc

January 22nd, 2003 at 12:07 pm

Avatar

There are a few other PDA-Based browsers out there, but I would test for Internet Explorer 3.0 as well. PocketPCs and Windows CE handheld PCs have a built in version of IE that broadcasts itself as IE 3.0.

They work rather well, but using the stripped down version of the skin would definitely save them some time, and woe be to anyone still using 3.0 on the desktop..;)

2 | Doc

January 22nd, 2003 at 12:09 pm

Avatar

Sorry, I forgot to ask.
How could I modify that string to redirect to a different page. I keep a separate PDA-Browser friendly page instead of using skins and I would like to redirect people using those browsers to the pda friendly page automatically.

Thanks.

3 | Amy

January 22nd, 2003 at 12:24 pm

Avatar

Yep – that should be an easy one, assuming that this check is done prior to sending out any HTML.

To do it, change

$skin = "13";

to

header("Location: http://seadoc.net/pda.php");

Side note: nice to see that I'm not the only person who claims Huntsville, AL as home who is reading this site. :)

4 | doc

January 22nd, 2003 at 8:04 pm

Avatar

Thanks. I knew it had to be something that easy, but my PHP vocabulary is pretty poor…;)

I put this below my DOCTYPE statement and before the <html> tag.. Thats the correct place, or should it be in the HEAD section??

5 | bobby g.

January 23rd, 2003 at 12:14 pm

Avatar

hi amy–

just fyi, the "Avant" browser is an IE-shell for Windows. it's pretty cool. it's different than the AvantGo service for handhelds.

6 | magenta

January 23rd, 2003 at 6:26 pm

Avatar

The Hiptop is a very nice browser-cellphone. Mine reports a user-agent string of Mozilla/5.0 (compatible; AvantGo 3.2; ProxiNet; Danger hiptop 1.0) (which means the AvantGo check will work for it too).

7 | Arno

January 24th, 2003 at 6:16 am

Avatar

Here in Holland and other parts of Europe, I-mode is introduced. I-mode was first developed by NTT-DoCoMo in Japan. It uses cHTML as markup language. I don't know what the browser broadcasts itself like, maybe someone else here does?

Also, there is the Live! Service by Vodafone which is similar to I-mode. I know that uses wap 1.2 (is that a possible ml?). But I am not sure whether you can visit only pages on a "closed" network for that service or that it is possible to request regular internet URL's?

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements