Dec 15 2009

Redirect users to another page or sub domain when they come to your site from a mobile devices

First Stategy:

Second Strategy:

Redirecting users based on their browser to a mobile subdomain

Put this in the head of your web page

<script language="javascript" type="text/javascript">
function browserCheck() {
    var agt = navigator.userAgent.toLowerCase();
    if (agt.indexOf("windows ce") != -1) return true;
    if (agt.indexOf("palmsource") != -1) return true;
    if (agt.indexOf("palmos") != -1) return true;
    if (agt.indexOf("midp-") != -1) return true;
    if (agt.indexOf("portalmmm") != -1) return true;
    if (agt.indexOf("symbian os") != -1) return true;
    if (agt.indexOf("up.browser") != -1) return true;
    if (agt.indexOf("mobilephone") != -1) return true;
    if (agt.indexOf("nokia") != -1) return true;
    if (agt.indexOf("docomo") != -1) return true;
    if (agt.indexOf("blackberry") != -1) return true;
    if (agt.indexOf("iphone") != -1) return true;
    if (agt.indexOf("ipod") != -1) return true;
    if (agt.indexOf("itouch") != -1) return true;
    else return false;
}
 
var browserName = browserCheck()
if (browserName) {
    document.location = "http://mobile.secondstrategy.com";
} else if (screen.width <= 699) {
    document.location = "http://mobile.secondstrategy.com";
}
</script>

Tags: , , , ,