Getting websites to detect our mobile browser
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?
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.
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.
精彩评论