I created mobile site for existing webpage and in it, I placed the code in mobile folder like www.testing.com/mobile and it works fine.
But what I need to do is if the user visited from mobile it should be redirected to mobile page and user visited from web it goes to default pages.
Here I used:
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0" />
to fit the page but url shows like m.tesing.com for mobile how to do this
By browser agent or any other ways. Thanks.
Download this detectmobile.js and make this changes in your head tag
<head>
<script src="detectmobile.js"></script>
<script>
try {
// This is the URL where mobile
detectmobile.defaultMobileURL = "http://m.testing.com";
detectmobile.process();
} catch(e) {
// Make sure that in the fault modes
// we do not interrupt execution of other Javascript code
}
</script>
</head>
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