简体   繁体   English

带有完整链接的移动设备重定向可转到完整网站

[英]Mobile redirect with full link to go to full site

I would like to finally find a solution for this with maybe some steps. 我想也许可以通过一些步骤最终找到解决方案。 i have the below javascript to point to a mobile site. 我有以下javascript指向移动网站。 and this works well. 而且效果很好。

<script type="text/javascript">
if ((navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)|(Windows Phone)|(BlackBerry)/i))) {
    document.location = "http://www.c5mobile.com/drglenn/index.html";
}
(function(a,b) {
    if (document.cookie.indexOf('fullsite') > -1) {
        return; // skip redirect
    }
    if (location.search.indexOf('fullsite') > -1) {
        document.cookie = 'fullsite=true; path=/;'
        return; // skip redirect
    } 
})(navigator.userAgent || navigator.vendor || window.opera, 'http://www.c5mobile.com/drglenn/index.html')
</script>

But on the mobile site i would like to go to the full site , but it keeps looping. 但是在移动站点上,我想转到完整站点,但是它一直循环播放。 this is the link im using below. 这是下面使用的链接。

<a href="http://drdibart.com?fullsite=true">Full site</a>

anyone have any thoughts on why it keeps looping back to the mobile site? 有人对它为什么不断循环回到移动网站有什么想法?

I think adding this will work no? 我认为添加此功能行不通?

if ( (navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)|(Windows Phone)|(BlackBerry)/i)) && location.search.indexOf('fullsite') < 0 ) {
    document.location = "http://www.c5mobile.com/drglenn/index.html";
}

I only added 我只加了

&& location.search.indexOf('fullsite') < 0

as the second condition to the if statement. 作为if语句的第二个条件。 Currently the redirect will happen in the fist if statement of your script 当前,重定向将首先在您的脚本的if语句中发生

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM