Bidirectional Redirect to Mobile site & switch back to Desktop Site

I asked this question in the Mobile forum and found out it’s a PHP question. I have a desktop and mobile site on two different domains www.domainname.com and m.domainname.com. It is set up to automatically redirect from www.domainname.comm.domainname.com when it’s visited on a mobile device. The part I am have difficulties with is being able to give the visitor an option to switch between the mobile site and the desktop site for mobile users. I have 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 = "http://m.domainname.com/";
}
//-->
</script>

Thank you ahead of time?

I’d have a link on your mobile site that lets you go to desktop, and if users click that link, I’d set a SESSION variable which (if set) lets users stay on desktop. I wouldn’t use JS for this since users can turn JS off. Handle this in PHP.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.