Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect a page request is from mobile or desktop client side

We have developed a website which has general homepage and mobile page, one is for mobile and other is for PC.

I want code to detect the device automatically and navigate to the mobile homepage if the user is from mobile and navigate to the homepage(general) if the user is from PC and problem is it should be using JavaScript or plain HTML.

like image 705
user1134567 Avatar asked Jan 06 '12 15:01

user1134567


3 Answers

http://detectmobilebrowsers.com/ has an open source javascript function to detect a mobile browser that you can use.

like image 94
ronme Avatar answered Oct 17 '22 15:10

ronme


To determine this you need to check the HTTP header for the request for your website, in particular the User-Agent string.

You haven't mentioned what technologies you're using, but you can redirect at the web-server level or within your application.

like image 20
m.edmondson Avatar answered Oct 17 '22 16:10

m.edmondson


Don't make separate sites. Use reactive design. The browser on my phone is just as good as the one on my desktop.

like image 31
tkone Avatar answered Oct 17 '22 16:10

tkone