简体   繁体   中英

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. 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. Currently the redirect will happen in the fist if statement of your script

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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