Purpose of this document

It can be useful to provide users with the ability to change their preference for the mobified or desktop site. This document provides the code required to opt a user out of or into a mobified site.


  • A working knowledge of HTML and JavaScript
  • Access to your desktop site HTML

Switching from mobified to desktop

To change a user's preference from the mobified site to the desktop site call Mobify.desktop(). To create a "View Full Site" link, you can place the following HTML in your template:

<a href="#" onclick="Mobify.desktop(); return false;">
    View Full Site

Switching from desktop to mobified

To change a user's preference from the desktop site to the mobified site you must set a cookie on the user's browser. To create a "View Mobile Site" link, you can use the following HTML in your desktop site:

<a href="#" onclick="document.cookie='mobify-path=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';location.reload()">
    Back to Mobile

Only show the back to mobile link on a mobile device

Generally, you won't want to show a "Back to Mobile" link on a non-mobile device, so we can conditionally insert this element into your desktop site based on the device:

<div id="mobile-site"></div>
<script type="text/javascript">
    if (/ip(hone|od)|android.*(mobile)|blackberry.*applewebkit/i.test(navigator.userAgent)) {
        var backToMobile = document.createElement("div");
        backToMobile.innerHTML = '<a href="#" onclick="document.cookie=\'mobify-path=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/\';location.reload()">Mobile Site</a>';
Last Edited