I want to check whether the user is viewing my site from a mobile device or PC. If it’s a mobile device, I want to redirect my site URL like Google does…
If possible I would like to implement this in JavaScript. How can I do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
See this existing question.
You will have better luck doing this server side, as many mobile browsers don’t even support JavaScript. Basically you want to check the user agent and compare to a list of known mobile browsers.