Mobile redirect but not when coming from Mobile site

Hello, i have this script and it works fine. I have it on the Desktop page and when a user enters it they get a question to be redirected to mobile page, this works fine. But i then have on the mobile page a link back to Desktop page, but when this link is clicked and the user gets to the Desktop page they will get the quetsion again. So my question is. Is there a way to let the Desktop page know that the user have clicked the link in Mobile page and if so do not show the Question again?
Thank you.

The code i have now:

<script type="text/javascript">
var isMobile = (/iphone|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent) && confirm('Realy?'));
if (isMobile)
{
   location.replace("mobile_site.html");
}  
</script>

Set a cookie or something (if they choose the desktop version link) and on your desktop page, check to see if that cookie exists.

Or set something in localstorage? Should work :slight_smile: .

Thank’s for your reply, but how can i do this? do you have an example please?
Thank you.

A good set of cookie handling functions can be found at http://snipplr.com/view/45954/cookie-handling-functions/
Those functions let you easily create cookies, read cookies, and erase them.

For example:

if (readCookie('linkOrigin') === 'footer') {
    // do stuff here
}
eraseCookie('footer');

Thank’s. I’m trying to use only java/jquery script. So i also have this code. Any one know how to combind my first script with this one? Thank you.

<script>
if( /Android|webOS|iPhone|iPod|BlackBerry|IEMobile/i.test(navigator.userAgent) &&
    !window.location.href.contains("#redirected") ) {
window.location = "my_mobile_page.html";
}
</script>

And in the link back to Desktop page:

<a href="my_desktop_page.html/?ref=desktop#redirected">Link back to desktop website</a>

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