[Last Call] Learn how to a build a cloud-first strategyRegister Now


What code can I write that senses whether my user is on a mobile phone as opposed to a desktop?

Posted on 2012-08-29
Medium Priority
Last Modified: 2012-08-30
I am curious to know whether there's some script I can write that determines whether or not my user is attempting to access my site using a computer browser or a phone. In the event that they're using a phone, I'm wanting to redirect them to a more mobile friendly site.

Can it be done and if so, how?
Question by:brucegust

Assisted Solution

by:Ahmed Merghani
Ahmed Merghani earned 668 total points
ID: 38348838
You can use this class:
I think this is what you need.
LVL 36

Assisted Solution

by:Loganathan Natarajan
Loganathan Natarajan earned 664 total points
ID: 38348902
You could also try this script, http://detectmobilebrowsers.mobi/
LVL 34

Accepted Solution

Beverley Portlock earned 668 total points
ID: 38349242
Depending on user agent strings can be hit and miss. A better way may be to look at CSS3 capabilities. Most mobile devices fully implement CSS3 media queries



Author Closing Comment

ID: 38349669

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month17 days, 20 hours left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question