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.
http://detectmobilebrowsers.com/ has an open source javascript function to detect a mobile browser that you can use.
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.
Don't make separate sites. Use reactive design. The browser on my phone is just as good as the one on my desktop.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With