views:

558

answers:

2

I've been asked to find out a sensible way to make the majority of popular websites detect our browser - which is functionally complete, but is running on rather constrained hardware - as a "mobile" browser. The idea is that the heaviest popular websites seem to have mobile versions, which render much faster and fit better on the screen.

I've looked at the inverse question, which tells me that there isn't an obvious standard way of doing it - http://www.brainhandles.com/techno-thoughts/detecting-mobile-browsers is a case in point. This is borne out by looking at a variety of User-Agent strings from popular mobile and desktop browsers.

So far the best idea we can come up with is to add "Mobile" to the string somewhere, since this is the main visible difference between Safari for iPad/iPhone and for Windows/Mac. Does anyone have a better idea?

+1  A: 

So far the best idea we can come up with is to add "Mobile" to the string somewhere, since this is the main visible difference between Safari for iPad/iPhone and for Windows/Mac. Does anyone have a better idea?

This won't work. The vast majority of mobile phones don't include "Mobile" in their user agents. Here's a fairly huge list of mobile user agents. As you can see, there's no consistency. On top of that, new user agents are being added to the market on a weekly basis.

ceejayoz
It's true that *looking* for "Mobile" would not, in itself, be a reliable method for *detecting* a mobile browser. But I'm looking for a way to *mark* a browser as mobile.
Chromatix
It's going to vary, then, and there's not going to be a *reliable* method. Some sites are going to look for "Mobile" in conjunction with "iPhone", others are going to look for "MobileSafari", etc.
ceejayoz
+2  A: 

If uniquely identifying yourself is unimportant you could simply copy the important parts of the User Agent string for a popular mobile device... one which would be an obvious omission from any mobile detection script.

Ty W