3

i'm having a finished website and need to optimize it for mobile devices (ipad/iphone/smartphones ..). what's the best way to detect which mobile device/browser is used? (eg. by jquery-plugin) thanks

2 Answers 2

2

JavaScript/jQuery is not the best way at all; apart from iPhones etc remember there are also Nokias, and other non-smart phones, which may or may not run JavaScript at all, and if they do, it won't be particularly quickly. Attempting to reconfigure your site using JavaScript on a phone over a few years old is pretty much just going to freeze the phone for at least a second or two whenever a page loads.

I would strongly suggest you look into doing this on the server side as much as possible - even if it's as simple as just swapping the stylesheet. At the basic level you can check the User-Agent header sent by the browser and work it out from there. In PHP, use the get_browser function.

Sign up to request clarification or add additional context in comments.

Comments

0

You could tell the device between Android/iPad/iPhone/BlackBarry etc. using User-Agent in JavaScript or PHP. See this article: http://graphicmaniacs.com/note/detecting-iphone-ipod-ipad-android-and-blackberry-browser-with-javascript-and-php/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.