Jquery:将用户重定向到移动网站 - 当用户点击转到完整网站时不重定向回移动网站?

Jquery: Redirect user to mobile site - when user clicks go to full site don't redirect back to mobile site?

我正在使用以下脚本将移动用户重定向到我的移动网站。

我在 header.php 中有我的代码,然后通过我的 index.php 文件包含它。

header.php:

<script>
function urlParam(name){
            var results = new RegExp('[\?&amp;]' + name + '=([^&amp;#]*)').exec(window.location.href);
            if(results)
                return results[1] || 0;
            else
                return '';
        }

        if(urlParam('view') == 'full'){ 
        }
        if(urlParam('view') == ''){
            // <![CDATA[
            var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));  
            if (mobile) { 
                    document.location = "http://m.hewdenportal.co.uk";  
            }  
            // ]]>
        }
</script>

index.php:

include 'header.php';

在我的移动网站上,我有以下 link 应该会将用户带到我的完整网站:

<a href="http://www.hewdenportal.co.uk?view=full" data-ajax="false">Full Site</a>

出于某种原因,这似乎无法让用户留在完整网站上,而是不断将他们重定向到移动网站。有人可以告诉我哪里出错了吗?

谢谢

更好的是

function getUrlParameter(sParam)
{
    var sPageURL = window.location.search.substring(1);
    var sURLVariables = sPageURL.split('&');
    for (var i = 0; i < sURLVariables.length; i++) 
    {
        var sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] == sParam) 
        {
            return sParameterName[1];
        }
    }
}         

var viewType = getUrlParameter('view');
var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));  


if(viewType=='full'){
  //Redirect to Full site
  document.location = "http://www.hewdenportal.co.uk";  
} else if(viewType=='mobile'){
  //Redirect to Mobile 
  document.location = "http://m.hewdenportal.co.uk";   
} else if(mobile){
    document.location = "http://m.hewdenportal.co.uk";  
} else {
    //No parameter , show desktop site
    document.location = "http://www.hewdenportal.co.uk";  
}

说明:首先测试他是点击移动设备 link 还是桌面设备,如果点击桌面设备,则显示完整站点,如果点击移动设备 link 则显示移动设备。如果他使用的是移动设备并且没有点击任何 link 然后默认情况下我们会检查他的设备并向他显示移动网站。

更多信息Read here