On 1/6/11 8:10 PM, Mike Kear wrote:
I have to convert a client site to enable phone users to use the site
and I was wondering what is the best method to detect the mobile user
agent and switch the css sheet?
As far as I have seen, there are a few ways to do this - which is
best? (or maybe the way to put it is 'least bad')
[A] a link at the top of the normal page, linking to a mobile
version of the page. (yuk)
[B] javascript detection (but there are thousands of mobile
devices to detect. YUK )
[C] Use CSS @media handheld (but many mobile phones don't support
the handheld media type )
[D] server side detection using CGI.User_Agent (but there are so
many user agents to detect)
[E] screen resolution detection (but is that reliable?)
Are there any other ways to do this?
Rather than doing a "switch" for mobile agents, I read recently a
proposal to do basic styling for mobile first. Then filter "advanced"
styles for browsers, from smart phones to desktops that understand
@media queries, simply by declaring some @media filters at the bottom of
the style sheet.
I don't remember where I read it, but it seems to me to have other
advantages--old browsers like IE6 would only get the simple styles, too,
making it much easier to give IE6 visitors a pleasant experience without
the usual extensive "fix-ups" some layouts seem to need.
While I don't have a link to the original, very short article, the idea
has been taken up by others:
<http://www.slideshare.net/bryanrieger/rethinking-the-mobile-web-by-yiibu>
(If that breaks, try http://goo.gl/VqJE )
The downside is that neither IE7 nor IE8 understand @media queries. The
idea I am playing with uses Paul Irish's "Conditional stylesheets vs CSS
hacks" idea to filter rules for IE 6-8.
<http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/>
(Broken? try http://goo.gl/CRQY )
I'll certainly be interested in any other possibilities. I have not got
very far with this myself...
Cordially,
David
--
*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [email protected]
*******************************************************************