Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 指定请求桌面站点位置_Javascript_Php_Html_Css - Fatal编程技术网

Javascript 指定请求桌面站点位置

Javascript 指定请求桌面站点位置,javascript,php,html,css,Javascript,Php,Html,Css,如何指定“请求桌面站点”选项的位置 目前,我正在运行此代码 var detector = new MobileDetect(window.navigator.userAgent); if(detector.mobile() != null || detector.phone() != null || detector.tablet() != null){ document.location = '/mobile/login'; } 它在登录页面工作,但当我直接导

如何指定“请求桌面站点”选项的位置

目前,我正在运行此代码

var detector = new MobileDetect(window.navigator.userAgent);
    if(detector.mobile() != null || detector.phone() != null || detector.tablet() != null){
        document.location = '/mobile/login';
    }
它在登录页面工作,但当我直接导航到/mobile/signup,并单击requestdesktop站点时,它返回的是移动注册站点,而不是桌面

另一方面,

如果我转到/desktop/signup,它会将我重定向到/mobile/signup 这很好,我可以请求桌面站点将我重定向到/desktop/signup,但是如果我直接转到/mobile/signup,我无法请求桌面站点


我目前正在使用mobile detect.js

如果您有两个不同的文件夹,分别名为
desktop
mobile
,请在
desktop
文件夹中的文件中添加以下脚本:

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");}
    }

构建类似的脚本并添加到
mobile
文件夹中的文件。

您是否检查了
if
条件返回中的那些函数调用?是否可以共享重定向到桌面站点的代码?