简体   繁体   中英

Specify Request Desktop Site Location

How do I specify the location of the 'Request desktop site' option.

Currently, I have this code running

var detector = new MobileDetect(window.navigator.userAgent);
    if(detector.mobile() != null || detector.phone() != null || detector.tablet() != null){
        document.location = '/mobile/login';
    }

It works at login page, but when I navigate directly to the /mobile/signup, and I click request desktop site, it returns the mobile signup site not the desktop.

On the other hand,

If I go to /desktop/signup, it redirects me to the /mobile/signup Which is good and I can request desktop site redirecting me to /desktop/signup, but if I go directly to /mobile/signup I cannot request desktop site.

I am currently using mobile-detect.js

If you have two different folders named desktop and mobile then add below script in files present at desktop folder:

var detector = new MobileDetect(window.navigator.userAgent);
    if(detector.mobile() != null || detector.phone() != null || detector.tablet() != null){
        var currentLocation = window.location.href;

       if (currentLocation.indexOf("desktop") > -1){
       document.location.href = currentLocation.replace("desktop","mobile");}
    }

construct similar script and add to files present in mobile folder.

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