I am in the proccess of making a site, i want a desktop version and a mobile version. What javascript code do i need to put into my html code to detect what device is viewing the page and if it was a mobile redirect it to my mobile verson of the site? my second problem is how to make a link back from the mobile site to the desktop site?
Asked
Active
Viewed 103 times
3 Answers
1
The best way would be to do it at the server level, or back-end level before it even reaches the user. It's a bad user experience to land on a web page, wait for it to load the javascript and then redirect again.

Samer
- 973
- 1
- 6
- 15
0
Jayesh answer should work, however In the future it might be handy to design responsively (content that automatically scales to the users screen size) to minimize loading times and maximize efficiency!

dsherv
- 81
- 9
-1
There is lots of help on this,
It is done by checking user agent property,
String userAgent = request.getHeader("User-Agent");
you can visit, Detecting Device Type in a web application