I have a desktop and mobile site on two different domains www.domainname.com and m.domainname.com. I want to set up an automatic redirect from www.domainname.com → m.domainname.com when it’s visited on a mobile device, but also give the visitor an option to switch between desktop and mobile versions for mobile users. I searched multiple forums but they only talk about toggling the page.
Can anyone lay out the steps to do something like this? Below is what I currently use inside the desktop site , but this only redirects one way, and keeps redirecting to the mobile site if users tries to access the desktop site on their mobile device.
<script type="text/javascript">
<!--
if (screen.width <= 800) {
document.location = "m.domainname.com";
}
//-->
</script>