[Web4lib] Mobile identification code

John Bickar jbickar at stanford.edu
Wed Aug 25 14:07:48 EDT 2010


When doing user-agent detection (as below), is it preferable to do it at the Apache level or the PHP level? Or are there pros and cons to both? (Setting aside the need to keep the list of user agents updated.)

-John Bickar
Stanford University

----- Original Message -----
> Dawn,
> 
> I've been using to different sources of mobile-detection code.
> 
> For our library website, where I have access to PHP, I use the code
> downloadable from:
> http://detectmobilebrowsers.mobi/
> (Free for non-commercial use, commercial license fees apply otherwise)
> The PHP is truly elegant, and I like it quite a bit.
> 
> For our library catalog, where we can't execute PHP code, I use an
> excerpt of the JavaScript code available at:
> http://detectmobilebrowser.com/
> This is a less elegant approach, but it works.
> 
> You can also do some non-script-based detection using the media
> attributes of a CSS <link> tag, but that path is fraught with peril.
> An intro to this approach can be found in Jonathan Stark's excellent
> book _Building iPhone Apps with HTML, CSS, and Javascript_ from
> O'Reilly. (see p16).
> 
> I strongly recommend that book (and probably its forthcoming
> Android-app companion book) to anyone interested in learning to build
> mobile-friendly websites. Despite the "iPhone app" orientation of the
> title, it is an excellent introduction to building mobile websites.
> (I'm really surprised that I've not found any other books that really
> plumb this territory. I'm curious if anyone else has, but I should
> probably post that as a separate thread.)
> 
> Good luck,
> Ken
> 
> 
> _______________________________________________
> Web4lib mailing list
> Web4lib at webjunction.org
> http://lists.webjunction.org/web4lib/




More information about the Web4lib mailing list