Mobile Phone/PDA Web Browser Screen Size Detection

Posted 2008-07-29 in Mobile Web by Johann.

iPhone

Photo by mawel. Some rights reserved.

Screen size detection of mobile phones and PDAs seems to be a minefield – I had planned to spend minutes on this…

Screen Size in the User-Agent

IEMobile and Opera Mobile on Windows Mobile and the Palm Blazer browser send the screen size in the user agent string using a WIDTHxHEIGHT form. Examples include Dopod818Pro/Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320; Dopod818 Pro) or Xda_trion; 240x320 (compatible; MSIE 6.0; Windows CE; IEMobile 6.12). A simple regular expression like ([0-9]{3})x([0-9]{3}) should work here.

Opera Mini

Opera Mini sends a X-OPERAMINI-PHONE-UA header with the request that contains a handset-specific user agent string whose value ends with …PPC; 240x320 on my PDA.

IEMobile

IEMobile additionally sends a UA-PIXELS: 320x240 header with its requests.

X-OS-PREFS

Featured in older Opera browsers on Symbian. Looks like X-OS-Prefs: fw:176; fh:208; ….

PROFILE, X-WAP-PROFILE, X-WAP-REMOVEDPROFILE, OPT

WAP-era headers that point to a UAProf profile of the mobile device. This URL needs to be loaded and parsed for the prf:ScreenSize element. Seems to be mostly used in Nokia mobile browsers.

UA-PIXELS, X-UP-DEVCAP-SCREENPIXELS, X-JPHONE-DISPLAY

These seem to be present in certain (unmentioned) mobile phones.

Other X-… Headers

There are even more X-… headers.

Given this complexity, does it make sense to invest in a abstraction library like WURFL? I see less of the “old” mobile browsers every day and WURFL is never complete anyway.

Subscribe

RSS 2.0, Atom or subscribe by Email.

Top Posts

  1. DynaCloud - a dynamic JavaScript tag/keyword cloud with jQuery
  2. 6 fast jQuery Tips: More basic Snippets
  3. xslt.js version 3.2 released
  4. xslt.js version 3.0 released XML XSLT now with jQuery plugin
  5. Forum Scanners - prevent forum abuse
  6. Automate JavaScript compression with YUI Compressor and /packer/

Navigation